Class Stack<T>
└
Object
Implemented Interfaces:
An implementation of the stack abstract data type. A stack is a collection of elements which operates in "LIFO" (last in, first out) order; that is, the element most recently added to the stack is the first one retrieved.
- Source Code:
- View Source
Field Summary
Inherited Fields:
Instance Method Summary
push (v :
)T - Pushes a new element onto the stack.
pop ():T - Pops the top value from the stack and returns it.
insert (depth :
,Int value :
)T - Inserts a new element at the specified depth.
removeIndex (depth :
):Int T -- index operator --
[] (depth :
):Int T - Returns the value at the given depth in the stack.
clear ()- Removes all elements from the stack.
Fields
The number of elements on the stack.
Instance Methods
@pre(count > 0)
method pop
():T
Pops the top value from the stack and returns it.
Returns the value at the given depth in the stack. The top element (most recently pushed) is
element 0, and the bottom element (earliest pushed) is element count - 1
.
- Parameters:
-
- value of typedepth Int
method clear
()
Removes all elements from the stack.