D 2.0
About Japanese Translation

www.digitalmars.com
Last update Sat Mar 6 18:01:30 2010

std.array

License:
Boost License 1.0.

Authors:
Andrei Alexandrescu

ElementType!(Range)[] array(Range)(Range r);
入力レンジ r の内容を持った配列を新しくアロケートします。

Example:
auto a = array([1, 2, 3, 4, 5][]);
assert(a == [ 1, 2, 3, 4, 5 ]);

bool empty(T)(in T[] a);
レンジの基本関数 empty の、組み込み配列用の実装です。 ドット式を使って非メンバ関数をメンバ関数のように呼び出せるという仕様を用いると、 array.empty という式を empty(array) と同じ意味として使用できます。

Example:
void main()
{
    auto a = [ 1, 2, 3 ];
    assert(!a.empty);
    assert(a[3 .. $].empty);
}

void popFront(T)(ref T[] a);
レンジの基本関数 popFront の、組み込み配列用の実装です。 ドット式を使って非メンバ関数をメンバ関数のように呼び出せるという仕様を用いると、 array.popFront という式を popFront(array) と同じ意味として使用できます。

Example:
void main()
{
    int[] a = [ 1, 2, 3 ];
    a.popFront;
    assert(a == [ 2, 3 ]);
}

void popBack(T)(ref T[] a);
レンジの基本関数 popBack の、組み込み配列用の実装です。 ドット式を使って非メンバ関数をメンバ関数のように呼び出せるという仕様を用いると、 array.popBack という式を popBack(array) と同じ意味として使用できます。

Example:
void main()
{
    int[] a = [ 1, 2, 3 ];
    a.popBack;
    assert(a == [ 1, 2 ]);
}

typeof(A[0]) front(A)(A a);
void front(T)(T[] a, T v);
レンジの基本関数 front の、組み込み配列用の実装です。 ドット式を使って非メンバ関数をメンバ関数のように呼び出せるという仕様を用いると、 array.front という式を front(array) と同じ意味として使用できます。

Example:
void main()
{
    int[] a = [ 1, 2, 3 ];
    assert(a.front == 1);
}

typeof(A.init[0]) back(A)(A a);
レンジの基本関数 back の、組み込み配列用の実装です。 ドット式を使って非メンバ関数をメンバ関数のように呼び出せるという仕様を用いると、 array.back という式を back(array) と同じ意味として使用できます。

Example:
void main()
{
    int[] a = [ 1, 2, 3 ];
    assert(a.front == 1);
}

void put(T, E)(ref T[] a, E e);
レンジの基本関数 put の、組み込み配列用の実装です。 ドット式を使って非メンバ関数をメンバ関数のように呼び出せるという仕様を用いると、 array.put(e) という式を put(array, e) と同じ意味として使用できます。

Example:
void main()
{
    int[] a = [ 1, 2, 3 ];
    int[] b = a;
    a.put(5);
    assert(a == [ 2, 3 ]);
    assert(b == [ 5, 2, 3 ]);
}

void insert(T, Range)(ref T[] array, size_t pos, Range stuff);
配列内の位置 posstuff を挿入します

void replace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff);
配列 array の、インデックスm from (inclusive) から to (exclusive) までの要素を stuff で置き換えます。 必要ならば配列の拡大あるいは縮小が行われます。

struct Appender(A : T[],T);
配列にデータを追加する出力レンジの実装です。 この実装は a ~= data を繰り返すよりも効率的なので、推奨されます。

Example:
string arr;
auto app = appender(&arr);
string b = "abcdefg";
foreach (char c; b) app.put(c);
assert(app.data == "abcdefg");

int[] a = [ 1, 2 ];
auto app2 = appender(&a);
app2.put(3);
app2.put([ 4, 5, 6 ]);
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);

this(T[]* p);
既存の配列へのポインタで Appender を初期化します。 Appender オブジェクトは追加をこの配列に対して行います。null が渡された (あるいはデフォルトコンストラクタが呼ばれた) 時は、Appender が自動的に新しい配列をアロケートします。

T[] data();
管理している配列を返します

const size_t capacity();
配列の容量 (メモリの再割り当てなしでデータ追加できる最大サイズ)を返します。

template put(U) if (isImplicitlyConvertible!(U,T) || isSomeChar!(T) && isSomeChar!(U))
管理している配列にデータを1つ追加します。

void put(U item);
管理している配列にデータを1つ追加します。

template put(Range) if (isForwardRange!(Range) && is(typeof(Appender.init.put(items.front))))
管理している配列にレンジ全体を追加します。

void put(Range items);
管理している配列にレンジ全体を追加します。

void clear();
管理している配列をクリアします。

Appender!(E[]) appender(A : E[], E)(A* array = null);
t で初期化した Appender!(T) オブジェクトを返すための便利関数です。