containers.segmentedvector
Dynamic array struct that never moves its contents in memory.
- struct SegmentedVector(T,long segmentSize = 1024) if (segmentSize > 0);
Dynamic array with manually managed memory that never moves its contents in memory.
Pointers to elements of a SegmentedVector are safe, unlike Vector which can move its contents on reallocation.
To simplify its implementation, SegmentedVector is not copyable at the moment. This could be changed if needed, however.- int opApply(int delegate(ref T) dg);
Foreach over values.
Foreach will iterate over all elements in linear order from start to end.
- int opApply(int delegate(size_t, ref T) dg);
Foreach over indices and values.
Foreach will iterate over all elements in linear order from start to end.
- void opCatAssign(U : T)(U element);
Append an element to the vector. (operator ~=)
- inout pure nothrow inout(T) opIndex(const size_t index);
Get element at the specified index.
Parameters:Returns:size_t index Index of the element to get. Must be within bounds. Element at the specified index.- void opIndexAssign(T value, const size_t index);
Set element at the specified index.
Parameters:size_t index Index of the element to set. Must be within bounds. - inout pure nothrow inout(T) front();
Access the first element of the vector.
- inout pure nothrow inout(T) back();
Access the last element of the vector.
- void popBack();
Remove the last element of the vector.
- const pure nothrow size_t length();
Get number of elements in the vector.
- const pure nothrow bool empty();
- void length(const size_t elements);
-
If the length will be lower than current length, trailing elements will be erased. If higher, the vector will be expanded. Values of the extra elements after expansion are NOT defined.
Parameters:
- void unittestSegmentedVector();
Unittest for SegmentedVector.