英語版
このページの英語版を見る
dmd.root.array
動的配列の実装。
Authors:
License:
ソース root/array.d
- pure nothrow @nogc @property inout(T)[]
peekSlice
(T)(inout(Array!T)*array
); - 与えられたルート配列を標準のD配列として公開する。Parameters:
inout(Array!T)* array
公開する配列。 Returns:与えられた配列を標準の D 配列として公開する。 - pure nothrow void
split
(T)(ref Array!Tarray
, size_tindex
, size_tlength
); - 配列をindex 。length index 以降をすべて右にずらして、要素を入れるスペースを確保する。Parameters:
Array!T array
分割する配列。 size_t index
配列を分割するインデックス。 size_t length
index から始まる要素の数。 - pure nothrow @nogc @safe T[]
reverse
(T)(T[]a
); - 配列をインプレースで反転する。Parameters:
T[] a
配列 Returns:を反転する。 - void
each
(alias callable, T)(ref Array!Tarray
)
if (is(ReturnType!(typeof((T t) => callable(t))) == void)); - 与えられた配列を繰り返し処理し、各要素に対して与えられた callable を呼び出す。配列が反復処理中に展開される可能性がある場合、foreach の代わりにこれを使用する。Parameters:
callable 各要素に対して呼び出す callable Array!T array
イテレートする配列 See Also:Examples:static immutable expected = [2, 3, 4, 5]; Array!int array; foreach (e ; expected) array.push(e); int[] result; array.each!((e) { result ~= e; }); assert(result == expected);
- int
each
(alias callable, T)(ref Array!Tarray
)
if (is(ReturnType!(typeof((T t) => callable(t))) == int)); - 与えられた配列を繰り返し処理し、各要素に対して与えられた callable を呼び出す。もしcallable が!= 0 を返せば、反復処理を停止し、その値を返す。 そうでなければ0を返す。 反復中に配列が拡張する可能性がある場合は、foreach の代わりにこれを使用する。Parameters:
callable 各要素に対して呼び出す callable Array!T array
イテレートする配列 Returns:が最後に返した値。callableSee Also:Examples:Array!int array; 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:から構成される静的配列である。
array
.Examples:enum a = [0, 1].staticArray; static assert(is(typeof(a) == int[2])); static assert(a == [0, 1]);
- bool
equal
(Range1, Range2)(Range1range1
, Range2range2
); - Returns:true 与えられた2つの範囲が等しい場合Examples:
enum a = [ 1, 2, 4, 3 ].staticArray; static assert(!equal(a[], a[1..$])); static assert(equal(a[], a[])); // 異なる型 enum b = [ 1.0, 2, 4, 3].staticArray; static assert(!equal(a[], b[1..$])); static assert(equal(a[], b[]));
- auto
filter
(alias predicate, Range)(Rangerange
)
if (isInputRange!(Unqual!Range) && isPredicateOf!(predicate, ElementType!Range)); - 与えられた述語に基づいて与えられた範囲をフィルタリングする。Returns:述語が返す要素のみを含む範囲。 trueExamples:
enum a = [1, 2, 3, 4].staticArray; enum result = a[].filter!(e => e > 2); enum expected = [3, 4].staticArray; static assert(result.equal(expected[]));
- auto
map
(alias callable, Range)(Rangerange
)
if (isInputRange!(Unqual!Range) && isCallableWith!(callable, ElementType!Range)); - 与えられた範囲をのんびりと繰り返し、各要素に対して与えられた callable を呼び出す。Returns:への各呼び出しの結果を含むcallableExamples:
enum a = [1, 2, 3, 4].staticArray; enum expected = [2, 4, 6, 8].staticArray; enum result = a[].map!(e => e * 2); static assert(result.equal(expected[]));
- auto
walkLength
(Range)(Rangerange
)
if (isInputRange!Range); - Returns:与えられた範囲の長さ。Examples:
enum a = [1, 2, 3, 4].staticArray; static assert(a[].walkLength == 4); enum c = a[].filter!(e => e > 2); static assert(c.walkLength == 2);
- template
ElementType
(R) - R の要素型に評価される。
- enum auto
isInputRange
(R); - 与えられた型が入力範囲インターフェイスを満たす場合、true に評価される。
- enum auto
isPredicateOf
(alias func, T); - func がT の値で呼び出され、 に変換可能な値を返す場合、true に評価される。 bool に変換可能な値を返す。
- enum auto
isCallableWith
(alias func, T); - func がT の値で呼び出される場合、true と評価される。
Copyright © 1999-2024 by the D Language Foundation
DEEPL APIにより翻訳、ところどころ修正。
このページの最新版(英語)
このページの原文(英語)
翻訳時のdmdのバージョン: 2.108.0
ドキュメントのdmdのバージョン: 2.109.1
翻訳日付 :
HTML生成日時:
編集者: dokutoku