Vector

A dynamic array with deterministic memory usage akin to C++'s std::vector or Rust's std::vec::Vec

Constructors

this
this(E[] elements)
Undocumented in source.
this
this(R range)
Undocumented in source.
this
this(Allocator allocator, E[] elements)
Undocumented in source.
this
this(Allocator allocator, R range)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

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

Members

Functions

back
inout(E) back()

Returns the last element

capacity
long capacity()

The current memory capacity of the vector

clear
void clear()

Clears the vector, resulting in an empty one

empty
bool empty()

If the vector is empty

front
inout(E) front()

Returns the first element

opAssign
void opAssign(R range)

Assigns from a range.

opBinary
Vector opBinary(T other)

Returns a new vector after appending to the given vector.

opDollar
long opDollar()
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
inout(E) opIndex(long i)

Access the ith element. Can throw RangeError.

opOpAssign
void opOpAssign(E other)

Append to the vector

opOpAssign
void opOpAssign(R range)

Append to the vector

opSlice
auto opSlice()

Returns a slice

opSlice
auto opSlice(long start, long end)

Returns a slice

opSliceAssign
void opSliceAssign(E value)

Assign all elements to the given value

opSliceAssign
void opSliceAssign(E value, long start, long end)

Assign all elements in the given range to the given value

opSliceOpAssign
void opSliceOpAssign(E value)

Assign all elements using the given operation and the given value

opSliceOpAssign
void opSliceOpAssign(E value, long start, long end)

Assign all elements in the given range using the given operation and the given value

popBack
void popBack()

Pops the last element off

popFront
void popFront()

When implemented, pops the front element off

reserve
void reserve(long newLength)

Reserve memory to avoid allocations when appending

shrink
bool shrink()

Shrink to fit the current length. Returns if shrunk.

shrink
bool shrink(long newLength)

Shrink to fit the new length given. Returns if shrunk.

Properties

length
long length [@property getter]

The current length of the vector

length
long length [@property setter]

Set the length of the vector

Meta