Vec

Kind of a std::vector replacement. Grow-only array, points to a (optionally aligned) memory location. This can also work as an output range. Vec is designed to work even when uninitialized, without makeVec. Warning: it is pretty barebones, doesn't respect T.init or call destructors. When used in a GC program, GC roots won't be registered.

Constructors

this
this(size_t initialSize, int alignment)

Creates an aligned buffer with given initial size.

Destructor

~this
~this()
Undocumented in source.

Postblit

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

Members

Aliases

opDollar
alias opDollar = length
put
alias put = pushBack
Undocumented in source.
size
alias size = length
ssize
alias ssize = length

Functions

capacity
size_t capacity()
clearContents
void clearContents()

Sets size to zero, but keeps allocated buffers.

fill
void fill(T x)

Fills the buffer with the same value.

indexOf
int indexOf(T x)

Finds an item, returns -1 if not found

isEmpty
bool isEmpty()
length
size_t length()
opCatAssign
void opCatAssign(T x)

Append an element to this buffer.

opIndex
inout(T) opIndex(size_t i)
opIndexAssign
T opIndexAssign(T x, size_t i)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(T x)

Append an element to this buffer.

opSlice
inout(T)[] opSlice()
opSlice
inout(T)[] opSlice(size_t i1, size_t i2)
popBack
T popBack()

Pop last element

pushBack
void pushBack(T x)

Append an element to this buffer.

pushBack
void pushBack(Vec other)

Appends another buffer to this buffer.

pushBack
void pushBack(T[] slice)

Appends a slice to this buffer. slice should not belong to the same buffer _data.

releaseData
T[] releaseData()

Move. Give up owner ship of the data.

removeAndReplaceByLastElement
void removeAndReplaceByLastElement(size_t index)

Removes an item and replaces it by the last item. Warning: this reorders the array.

removeAndShiftRestOfArray
void removeAndShiftRestOfArray(size_t index)

Removes an item and shift the rest of the array to front by 1. Warning: O(N) complexity.

removeAndShiftRestOfArray
void removeAndShiftRestOfArray(size_t first, size_t last)

Removes a range of items and shift the rest of the array to front. Warning: O(N) complexity.

resize
void resize(size_t askedSize)

Resizes a buffer to hold askedSize elements.

slength
ptrdiff_t slength()

Properties

ptr
inout(T)* ptr [@property getter]

Meta