std.array

机器翻译,还未校对,仅供参考

Jump to: empty popFront popBack front back put insert replace Appender data capacity AcceptedElementType clear appender

bool empty(T)(in T[] a);
Implements the range interface primitive empty for built-in arrays. Due to the fact that nonmember functions can be called with the first argument using the dot notation, array.empty is equivalent to empty(array).

实现范围接口原始 空 内置的数组。 因为可以用调用 nonmember 函数第一个参数使用该点表示法 数组时 空 是等效于 空 (array) 。

示例:

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

void popFront(T)(ref T[] a);
Implements the range interface primitive popFront for built-in arrays. Due to the fact that nonmember functions can be called with the first argument using the dot notation, array.popFront is equivalent to popFront(array).

实现范围接口原始 popFront 内置的数组。 因为可以用调用 nonmember 函数第一个参数使用该点表示法 数组时 popFront 是等效于 popFront (array) 。

示例:

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

void popBack(T)(ref T[] a);
Implements the range interface primitive popBack for built-in arrays. Due to the fact that nonmember functions can be called with the first argument using the dot notation, array.popBack is equivalent to popBack(array).

实现范围接口原始 popBack 内置的数组。 因为可以用调用 nonmember 函数第一个参数使用该点表示法 数组时 popBack 是等效于 popBack (array) 。

示例:

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);
Implements the range interface primitive front for built-in arrays. Due to the fact that nonmember functions can be called with the first argument using the dot notation, array.front is equivalent to front(array).
实现范围接口原始 前 内置的数组。 因为可以用调用 nonmember 函数第一个参数使用该点表示法 数组时 前 是等效于 前 (array) 。

示例:

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

T back(T)(T[] a);
Implements the range interface primitive back for built-in arrays. Due to the fact that nonmember functions can be called with the first argument using the dot notation, array.back is equivalent to back(array).
实现范围接口原始 回 内置的数组。 因为可以用调用 nonmember 函数第一个参数使用该点表示法 数组时 回 是等效于 回 (array) 。

示例:

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

void put(T, E)(ref T[] a, E e);
Implements the range interface primitive put for built-in arrays. Due to the fact that nonmember functions can be called with the first argument using the dot notation, array.put(e) is equivalent to put(array, e).
实现范围接口原始 把 内置的数组。 因为可以用调用 nonmember 函数第一个参数使用该点表示法 数组时 把 (e) 是等效于 把 (array,e) 。

示例:

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);
Inserts stuff in container at position pos.
在位置 pos 容器 中插入 的东西 。

void replace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff);
Erases elements from array with indices ranging from from (inclusive) to to (exclusive).
指数以至 从 清除从 数组 的元素 (包括), 到 (排他)。

Erases element from array at index from.
清除从在 从 的索引的 数组 元素。

Replaces elements from array with indices ranging from from (inclusive) to to (exclusive) with the range stuff. Expands or shrinks the array as needed.
从 数组 元素替换以至 从 的指数 (包括), 以 (独占) 与范围 的东西 。 扩展或收缩数组作为需要。

struct Appender(A : T[],T);
Implements an output range that appends data to an array. This is recommended over a ~= data because it is more efficient.
实现一个将数据追加到一个数组的输出范围。 这是建议通过 一 ~ = 数据 因为它是更有效。

示例:

auto arr = new char[0];
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);
Initialize an Appender with a pointer to an existing array. The Appender object will append to this array. If null is passed (or the default constructor gets called), the Appender object will allocate and use a new array.
初始化指向一个现有的数组的指针与 Appender 。 在 appender 对象将附加到此数组。 如果传递 空 (或默认的构造函数被调用), Appender 对象将分配并使用一个新的数组。

T[] data();
Returns the managed array.
返回托管的数组。

const size_t capacity();
Returns the capacity of the array (the maximum number of elements the managed array can accommodate before triggering a reallocation).
返回在 能力 的数组 (最大的元素数,托管的数组可容纳在触发一个重新分配之前)。

alias AcceptedElementType;
An alias for the accepted type to be appended.
要附加的接受类型的别名。

void put(AcceptedElementType item);
Appends one item to the managed array.
将一 项 追加到托管数组。

void put(AcceptedElementType[] items);
Appends another array to the managed array.
将另一个数组追加到托管数组。

void put(in char c);
void put(in char[] cs);
void put(in wchar dc);
void put(in wchar[] dcs);
void put(in dchar dc);
void put(in dchar[] wcs);
In case the managed array has type char[], wchar[], or dchar[], all other character widths and arrays thereof are also accepted.
以托管的数组了 Type Char [] 、 wchar [] ,或 dchar [] ,所有其他字符宽度和任何数组都是也接受。

void clear();
Clears the managed array.
清除托管的数组。

Appender!(E[]) appender(A : E[], E)(A* array = null);
Convenience function that returns an Appender!(T) object initialized with t.
返回一个 Appender!(T) 对象的方便函数用 t 初始化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值