Stack

Implementation of a stack optimized to reduce allocations.

Removing nodes from the stack using pop or clear will move them to a global stack of "free" nodes. The next time an item is added to the stack, it will reuse one of these previously freed nodes. This recycling mechanism makes it possible to significantly reduce the number of allocations as the program continues.

If version Fluid_MemoryStatistics is set, Stack will count the number of total nodes it has allocated per type and thread and expose then through totalNodeCount.

Constructors

this
this(T item)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

back
alias back = top
Undocumented in source.
removeBack
alias removeBack = pop
Undocumented in source.

Functions

clear
void clear()

Empty the stack.

empty
bool empty()
opIndex
StackRange!T opIndex()
opOpAssign
void opOpAssign(T item)
pop
T pop()

Remove the item at the top of the stack.

push
void push(T item)

Add an item to the stack.

top
inout(T) top()

Static functions

resetNodeCount
void resetNodeCount()

Reset totalNodeCount back to 0.

totalNodeCount
int totalNodeCount()

This special field is only available when version Fluid_MemoryStatistics is set. Stack will then count the number of total nodes it has allocated per type and thread.

Meta