NaStack

Stack, with no fixed data type for elements.

Right now its not used anywhere, but it migth be useful.

Constructors

this
this(uinteger size)

constructor size is the size in bytes, default is 64 KiB

Destructor

~this
~this()
Undocumented in source.

Members

Functions

clear
void clear()

empty stack, sets all bytes to zero, resets seek

pop
void pop(T val)

pops from stack

popArray
void popArray(T[] vals)

pops multiple from stack. first popped is last in array

push
void push(T element)

pushes to stack

pushArray
void pushArray(T[] elements)

pushes multiple elements to stack. last in array is first pushed

Properties

errored
bool errored [@property getter]

if an error has occured, since this was last called

seek
uinteger seek [@property getter]

seek index (number of bytes used on stack)

Examples

NaStack s = new NaStack();
s.push!integer(integer.max);
s.push!ubyte(255);
s.push!byte(127);
byte b;
b = 0;
ubyte ub;
ub = 0;
integer[] iA = [0];
assert(s.errored == false);
s.pop(b);
s.pop(ub);
s.pop(iA[0]);
assert(b == 127);
assert(ub == 255);
assert(iA[0] == integer.max);
iA = [integer.max, integer.max >> 1, 0, 1025];
s.pushArray(iA);
iA[] = 0;
s.popArray(iA);
assert(iA == [integer.max, integer.max >> 1, 0, 1025]);
s.push(cast(integer)integer.max);
s.push(cast(integer)integer.max >> 1);
s.push(cast(integer)0);
s.push(cast(integer)1025);
iA[] = 0;
s.popArray(iA);
assert(iA == [integer.max, integer.max >> 1, 0, 1025]);
assert(s.errored == false);
.destroy(s);

Meta