Sourceroot/array.d
Documentationhttps://dlang.org/phobos/dmd_root_array.html
peekSlice(T)(inout(Array!T)*array);inout(Array!T)*array | the array to expose. |
split(T)(ref Array!Tarray, size_tindex, size_tlength);Array!Tarray | the array to split. |
size_tindex | the index to split the array from. |
size_tlength | the number of elements to make room for starting atindex. |
reverse(T)(T[]a);T[]a | array |
each(alias callable, T)(ref Array!Tarray)| callable | the callable to call for each element |
Array!Tarray | the array to iterate |
staticimmutable expected = [2, 3, 4, 5];Array!intarray;foreach (e ; expected)array.push(e);int[] result;array.each!((e) { result ~= e;});assert(result == expected);
each(alias callable, T)(ref Array!Tarray)| callable | the callable to call for each element |
Array!Tarray | the array to iterate |
Array!intarray;foreach (e ; [2, 3, 4, 5])array.push(e);int[] result;const returnValue =array.each!((e) { result ~= e;if (e == 3)return 8;return 0;});assert(result == [2, 3]);assert(returnValue == 8);
staticArray(T, size_t n)(auto ref T[n]array);array.enum a = [0, 1].staticArray;staticassert(is(typeof(a) ==int[2]));staticassert(a == [0, 1]);
equal(Range1, Range2)(Range1range1, Range2range2);enum a = [ 1, 2, 4, 3 ].staticArray;staticassert(!equal(a[], a[1..$]));staticassert(equal(a[], a[]));// different typesenum b = [ 1.0, 2, 4, 3].staticArray;staticassert(!equal(a[], b[1..$]));staticassert(equal(a[], b[]));
filter(alias predicate, Range)(Rangerange)enum a = [1, 2, 3, 4].staticArray;enum result = a[].filter!(e => e > 2);enum expected = [3, 4].staticArray;staticassert(result.equal(expected[]));
map(alias callable, Range)(Rangerange)enum a = [1, 2, 3, 4].staticArray;enum expected = [2, 4, 6, 8].staticArray;enum result = a[].map!(e => e * 2);staticassert(result.equal(expected[]));
walkLength(Range)(Rangerange)enum a = [1, 2, 3, 4].staticArray;staticassert(a[].walkLength == 4);enum c = a[].filter!(e => e > 2);staticassert(c.walkLength == 2);
ElementType(R)isInputRange(R);isPredicateOf(alias func, T);isCallableWith(alias func, T);