Struct Stack
Stack implementation based on Array.
Properties
Name | Type | Description |
empty [get]
|
bool | Check if stack has no elements.
|
Methods
Name | Description |
free
()
|
Free memory allocated by Stack.
|
pop
()
|
Pop top element out.
|
pop
(value)
|
Non-throwing version of pop.
|
push
(v)
|
Push element to stack.
|
top
()
|
Top stack element.
|
topPtr
()
|
Pointer to top stack element.
|
Example
import std.exception: assertThrown;
Stack!int s;
assertThrown(s.pop());
s.push(100);
s.push(3);
s.push(76);
assert(s.top() == 76);
int v;
s.pop(v);
assert(v == 76);
assert(s.pop() == 3);
assert(s.pop() == 100);
assert(s.empty);
s.free();