The OpenD Programming Language

Vector

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

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

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.

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

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.

Properties

length
long length [@property getter]

The current length of the vector

length
long length [@property setter]

Set the length of the vector

Meta