File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,6 +197,27 @@ void nu_cleara(T)(ref T[] slice) {
197197 slice = null ;
198198}
199199
200+ /**
201+ Reverses the contents of the given range.
202+
203+ Params:
204+ range = The range to reverse the contents of.
205+ */
206+ pragma (inline, true )
207+ void nu_reverse (T)(auto ref T[] range) @nogc nothrow {
208+ import numem.core.memory : nu_swap;
209+ import numem.core.hooks : nu_memmove;
210+
211+ foreach (i; 0 .. range.length / 2 ) {
212+ T tmp;
213+ T* a = &range[i];
214+ T* b = &range[range.length - i];
215+ nu_memmove(&tmp, &a, T.sizeof);
216+ nu_memmove(&a, &b, T.sizeof);
217+ nu_memmove(&b, &tmp, T.sizeof);
218+ }
219+ }
220+
200221/**
201222 Creates a shallow duplicate of the given buffer.
202223
Original file line number Diff line number Diff line change @@ -45,6 +45,16 @@ template BaseElemOf(T) {
4545 alias BaseElemOf = T;
4646}
4747
48+ /**
49+ Gets the element type of the given range type $(D T).
50+ */
51+ template ElementType (T) {
52+ static if (is (typeof (T.init[0 ]) Y))
53+ alias ElementType = Y;
54+ else
55+ alias ElementType = void ;
56+ }
57+
4858/**
4959 Gets the original type of $(D T).
5060*/
You can’t perform that action at this time.
0 commit comments