Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

dmd.root.array

Dynamic array implementation.
Authors:
Walter Bright
License:
Boost License 1.0

Sourceroot/array.d

Documentationhttps://dlang.org/phobos/dmd_root_array.html

Coveragehttps://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/root/array.d

pure nothrow @nogc @property inout(T)[]peekSlice(T)(inout(Array!T)*array);
Exposes the given root Array as a standard D array.
Parameters:
inout(Array!T)*arraythe array to expose.
Returns:
The given array exposed to a standard D array.
pure nothrow voidsplit(T)(ref Array!Tarray, size_tindex, size_tlength);
Splits the array atindex and expands it to make room forlength elements by shifting everything pastindex to the right.
Parameters:
Array!Tarraythe array to split.
size_tindexthe index to split the array from.
size_tlengththe number of elements to make room for starting atindex.
pure nothrow @nogc @safe T[]reverse(T)(T[]a);
Reverse an array in-place.
Parameters:
T[]aarray
Returns:
reversed a[]
voideach(alias callable, T)(ref Array!Tarray)
if (is(ReturnType!(typeof((T t) => callable(t))) == void));
Iterates the given array and calls the given callable for each element.
Use this instead offoreach when the array may expand during iteration.
Parameters:
callablethe callable to call for each element
Array!Tarraythe array to iterate
See Also:
Examples:
staticimmutable expected = [2, 3, 4, 5];Array!intarray;foreach (e ; expected)array.push(e);int[] result;array.each!((e) {    result ~= e;});assert(result == expected);
inteach(alias callable, T)(ref Array!Tarray)
if (is(ReturnType!(typeof((T t) => callable(t))) == int));
Iterates the given array and calls the given callable for each element.
Ifcallable returns!= 0, it will stop the iteration and return that value, otherwise it will return 0.
Use this instead offoreach when the array may expand during iteration.
Parameters:
callablethe callable to call for each element
Array!Tarraythe array to iterate
Returns:
the last value returned bycallable
See Also:
Examples:
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);
T[n]staticArray(T, size_t n)(auto ref T[n]array);
Returns:
A static array constructed fromarray.
Examples:
enum a = [0, 1].staticArray;staticassert(is(typeof(a) ==int[2]));staticassert(a == [0, 1]);
boolequal(Range1, Range2)(Range1range1, Range2range2);
Returns:
true if the two given ranges are equal
Examples:
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[]));
autofilter(alias predicate, Range)(Rangerange)
if (isInputRange!(Unqual!Range) && isPredicateOf!(predicate, ElementType!Range));
Lazily filters the given range based on the given predicate.
Returns:
a range containing only elements for which the predicate returnstrue
Examples:
enum a = [1, 2, 3, 4].staticArray;enum result = a[].filter!(e => e > 2);enum expected = [3, 4].staticArray;staticassert(result.equal(expected[]));
automap(alias callable, Range)(Rangerange)
if (isInputRange!(Unqual!Range) && isCallableWith!(callable, ElementType!Range));
Lazily iterates the given range and calls the given callable for each element.
Returns:
a range containing the result of each call tocallable
Examples:
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[]));
autowalkLength(Range)(Rangerange)
if (isInputRange!Range);
Returns:
the length of the given range.
Examples:
enum a = [1, 2, 3, 4].staticArray;staticassert(a[].walkLength == 4);enum c = a[].filter!(e => e > 2);staticassert(c.walkLength == 2);
templateElementType(R)
Evaluates to the element type ofR.
enum autoisInputRange(R);
Evaluates totrue if the given type satisfy the input range interface.
enum autoisPredicateOf(alias func, T);
Evaluates totrue iffunc can be called with a value ofT and returnsa value that is convertible tobool.
enum autoisCallableWith(alias func, T);
Evaluates totrue iffunc be called withl a value ofT.
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 17:56:14 2026

[8]ページ先頭

©2009-2026 Movatter.jp