Initial release: April 2008
Kris
0.99.7
- struct Stack(V, int Size = 0) ¶
-
A stack of the given value-type V, with maximum depth Size. Note
that this does no memory allocation of its own when Size != 0, and
does heap allocation when Size == 0. Thus you can have a fixed-size
low-overhead instance, or a heap oriented instance.
- Stack* clear() ¶
-
- size_t size() [@property] ¶
-
Return depth of the stack
- size_t unused() ¶
-
Return remaining unused slots
- Stack clone() ¶
-
Returns a (shallow) clone of this stack, on the stack
- V dup() [@property] ¶
-
Push and return a (shallow) copy of the topmost element
- Stack* push(V value) ¶
-
Push a value onto the stack.
Throws an exception when the stack is full
- Stack* append(V[] value...) ¶
-
Push a series of values onto the stack.
Throws an exception when the stack is full
- V pop() ¶
-
Remove and return the most recent addition to the stack.
Throws an exception when the stack is empty
- V top() [@property] ¶
-
Return the most recent addition to the stack.
Throws an exception when the stack is empty
- V swap() ¶
-
Swaps the top two entries, and return the top
Throws an exception when the stack has insufficient entries
- V nth(size_t i) ¶
-
Index stack entries, where a zero index represents the
newest stack entry (the top).
Throws an exception when the given index is out of range
- Stack* rotateLeft(size_t d) ¶
-
Rotate the given number of stack entries
Throws an exception when the number is out of range
- Stack* rotateRight(size_t d) ¶
-
Rotate the given number of stack entries
Throws an exception when the number is out of range
- V[] slice() ¶
-
Return the stack as an array of values, where the first
array entry represents the oldest value.
Doing a foreach() on the returned array will traverse in
the opposite direction of foreach() upon a stack
- int opApply(scope int delegate(ref V value) dg) ¶
-
Iterate from the most recent to the oldest stack entries