std.array
License:Boost License 1.0. Authors:
Andrei Alexandrescu Copyright Andrei Alexandrescu 2008 - 2009. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at ) http:
//www.boost.org/LICENSE_1_0.txt
- Returns a newly-allocated array consisting of a copy of the input
range r.
Example:
auto a = array([1, 2, 3, 4, 5][]); assert(a == [ 1, 2, 3, 4, 5 ]);
- 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).
Example:
void main() { auto a = [ 1, 2, 3 ]; assert(!a.empty); assert(a[3 .. $].empty); }
- Implements the range interface primitive save for built-in
arrays. Due to the fact that nonmember functions can be called with
the first argument using the dot notation, array.save is
equivalent to save(array).
Example:
void main() { auto a = [ 1, 2, 3 ]; auto b = a.save; assert(b is 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).
Example:
void main() { int[] a = [ 1, 2, 3 ]; a.popFront; assert(a == [ 2, 3 ]); }
- 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).
Example:
void main() { int[] a = [ 1, 2, 3 ]; a.popBack; assert(a == [ 1, 2 ]); }
- 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).
Example:
void main() { int[] a = [ 1, 2, 3 ]; assert(a.front == 1); }
- 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).
Example:
void main() { int[] a = [ 1, 2, 3 ]; assert(a.front == 1); }
- 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).
Example:
void main() { int[] a = [ 1, 2, 3 ]; int[] b = a; a.put(5); assert(a == [ 2, 3 ]); assert(b == [ 5, 2, 3 ]); }
- Inserts stuff in container at position pos.
- 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.
- Implements an output range that appends data to an array. This is
recommended over a ~= data because it is more efficient.
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);
- 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.
- Returns the managed array.
- Returns the capacity of the array (the maximum number of elements the managed array can accommodate before triggering a reallocation).
- Appends one item to the managed array.
- Appends one item to the managed array.
- Appends an entire range to the managed array.
- Appends an entire range to the managed array.
- Clears the managed array.
- Convenience function that returns an Appender!(T) object initialized with t.