Array

One dimensional array.

struct Array (
T
) {}

Constructors

this
this(T[R] init, Allocator allocator)

Creates a new $(D_PSYMBOL Array) with the elements from a static array.

this
this(R init, Allocator allocator)

Creates a new $(D_PSYMBOL Array) with the elements from an input range.

this
this(R init, Allocator allocator)

Initializes this array from another one.

this
this(size_t len, T init, Allocator allocator)
this(size_t len, Allocator allocator)
this(Allocator allocator)

Creates a new $(D_PSYMBOL Array).

Destructor

~this
~this()

Destroys this $(D_PSYMBOL Array).

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

ConstRange
alias ConstRange = .Range!(const Array)

The range types for $(D_PSYMBOL Array).

Range
alias Range = .Range!Array

The range types for $(D_PSYMBOL Array).

insert
alias insert = insertBack

Inserts the el into the array.

Functions

clear
void clear()

Removes all elements.

get
inout(T[]) get()

Returns an array used internally by the array to store its owned elements. The length of the returned array may differ from the size of the allocated memory for the array: the array contains only initialized elements, but not the reserved memory.

insertAfter
size_t insertAfter(Range r, R el)
size_t insertAfter(Range r, T[R] el)

Inserts el before or after r.

insertBack
size_t insertBack(R el)
size_t insertBack(T[R] el)

Inserts the el into the array.

insertBefore
size_t insertBefore(Range r, R el)
size_t insertBefore(Range r, T[R] el)

Inserts el before or after r.

opAssign
typeof(this) opAssign(R that)

Assigns another array.

opAssign
typeof(this) opAssign(R that)

Assigns a range to the array.

opAssign
typeof(this) opAssign(T[R] that)

Assigns a static array.

opDollar
size_t opDollar()
opEquals
bool opEquals(typeof(this) that)
bool opEquals(R that)

Comparison for equality.

opEquals
bool opEquals(R that)

Comparison for equality.

opIndex
inout(T) opIndex(size_t pos)
opIndex
Range opIndex()
ConstRange opIndex()
opIndexAssign
T opIndexAssign(E value, size_t pos)
Range opIndexAssign(E value)

Assigns a value to the element with the index pos.

opIndexAssign
Range opIndexAssign(T[R] value)
Range opIndexAssign(Range value)

Assigns a range or a static array.

opSlice
Range opSlice(size_t i, size_t j)
ConstRange opSlice(size_t i, size_t j)
opSliceAssign
Range opSliceAssign(T[R] value, size_t i, size_t j)
Range opSliceAssign(R value, size_t i, size_t j)
Range opSliceAssign(Range value, size_t i, size_t j)

Slicing assignment.

remove
Range remove(Range r)

Remove all elements beloning to r.

removeBack
void removeBack()

Removes the value at the back of the array.

removeBack
size_t removeBack(size_t howMany)

Removes howMany elements from the array.

reserve
void reserve(size_t size)

Reserves space for size elements.

shrink
void shrink(size_t size)

Requests the array to reduce its capacity to fit the size.

Mixins

__anonymous
mixin DefaultAllocator
Undocumented in source.

Properties

back
inout(T) back [@property getter]
capacity
size_t capacity [@property getter]
empty
bool empty [@property getter]
front
inout(T) front [@property getter]
length
size_t length [@property getter]
length
size_t length [@property setter]

Expands/shrinks the array.

Mixed In Members

From mixin DefaultAllocator

allocator_
Allocator allocator_;

Allocator.

this
this(Allocator allocator)
allocator
shared(Allocator) allocator [@property getter]

This property checks if the allocator was set in the constructor and sets it to the default one, if not.

Parameters

T

Content type.

Examples

auto v = Array!int([5, 15, 8]);

assert(v.front == 5);
assert(v[1] == 15);
assert(v.back == 8);

auto r = v[];
r[0] = 7;
assert(r.front == 7);
assert(r.front == v.front);

Meta