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.
this
this(R range)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

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

Members

Aliases

MutE
alias MutE = Unqual!E
Undocumented in source.

Functions

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

free
void free()

Frees the memory and returns to .init

opAssign
void opAssign(R range)

Assigns from a range.

opBinary
Vector opBinary(T other)

Returns a new vector after appending to the given vector.

opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opDollar
long opDollar()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(R range)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(const(Vector!(E, OtherAllocator)) other)
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 from a range

opSlice
auto opSlice()

Returns a slice. @system because the pointer in the slice might dangle.

opSlice
auto opSlice(long start, long end)

Returns a slice. @system because the pointer in the slice might dangle.

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()

Pops the front element off

ptr
auto ptr()
Undocumented in source. Be warned that the author may not have intended to support it.
put
void put(E other)
Undocumented in source. Be warned that the author may not have intended to support it.
put
void put(R range)
Undocumented in source. Be warned that the author may not have intended to support it.
range
auto range(long start, long end)

Return a forward range of the vector contents. Negative end values work like in Python.

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. Cannot be made @safe due to reallocation causing pointers to dangle.

stringz
auto stringz()

Return a null-terminated C string @system since appending is not @safe.

Manifest constants

isElementMutable
enum isElementMutable;
Undocumented in source.

Properties

length
long length [@property getter]

The current length of the vector

length
long length [@property setter]

Set the length of the vector

Meta