DynamicQueue

ditto

Members

Functions

clear
void clear()

Removes all items from the queue.

free_space
ulong free_space()
is_empty
bool is_empty()

Tells whether the queue is empty.

length
size_t length()
pop
T* pop()

Pops an element from the queue and returns a pointer to that element. The value of the element must then be copied from the location pointed to before calling push() or pop() the next time.

push
T* push()

Reserves space for an element of the size T.sizeof at the queue and returns a pointer to it. The value of the element must then be copied to the location pointed to before calling push() or pop() the next time.

push
bool push(T element)

Pushes an element into the queue.

shrink
void shrink()

Shifts lefts currently used slots of the underlying array to optimize memory usage.

total_space
ulong total_space()
used_space
ulong used_space()
willFit
bool willFit(size_t bytes)

Finds out whether the provided number of bytes will fit in the queue.

Variables

auto_shrink
bool auto_shrink;

When set to 'true`, will automatically shift all items in the underlying array to utilize freed space. It is a recommended default.

Examples

auto queue = new DynamicQueue!(int);
queue.push(1);
queue.push(2);
queue.push(3);
test!("==")(*queue.pop(), 1);
test!("==")(*queue.pop(), 2);
test!("==")(*queue.pop(), 3);

Meta