Class: TypedStack
@include <TypedStack>
The TypedStack class provides a stack implementation which enforces type restrictions on its elements. After setting the stack’s type, all elements must be pointers to objects of that type or its subclasses.
Methods
@TypedStack.set_type
Scope: public
Sets the type of elements that this stack will hold. This method must be called before adding elements to the stack. The stack’s type cannot be changed after elements have been added.
Usage: @TypedStack.set_type $type
Parameters
type
- Type:
primitive
- The type to enforce for the elements of this stack.
- Type:
@TypedStack.push
Scope: public
Adds a value to the top of the stack, enforcing the specified type.
Usage: @TypedStack.push $value
Parameters
value
- Type:
primitive
- The value to add to the stack.
- Type:
@TypedStack.size
Scope: public
Echoes the number of elements in the stack.
Usage: @TypedStack.size
@TypedStack.pop
Scope: public
Pops the top element off the stack and echoes it.
Usage: @TypedStack.pop
@TypedStack.top
Scope: public
Echoes the top element of the stack.
Usage: @TypedStack.top
@TypedStack.clear
Scope: public
Removes all elements from the stack.
Usage: @TypedStack.clear
@TypedStack.empty
Scope: public
Echoes “true” if the stack is empty, “false” otherwise.
Usage: @TypedStack.empty