Collections-Stack

Stack
I implement a simple Stack. #push: adds a new object of any kind on top of the stack. #pop returns the first element and remove it from the stack. #top answer the first element of the stack without removing it.
errorEmptyStack
ifEmpty:ifNotEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
ifEmpty:ifNotEmptyDo:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
ifNotEmpty:
Evaluate the given block unless the receiver is empty.
If the block has an argument, eval with the receiver as its argument,
but it might be better to use ifNotEmptyDo: to make the code easier to
understand
ifNotEmptyDo:
Evaluate the given block with the receiver as its argument.
ifNotEmptyDo:ifEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
Evaluate the notEmptyBlock with the receiver as its argument
initialize
Subclasses should redefine this method to perform initializations on instance creation
isEmpty
isEmptyOrNil
Answer whether the receiver contains any elements, or is nil. Useful in numerous situations where one wishes the same reaction to an empty collection or to nil
linkedList
The stack is implemented with a LinkedList. Do NOT call this function, it
is for private use !
notEmptyCheck
Ensure the stack is not empty.
pop
Returns the first element and remove it from the stack.
push:
Adds a new object of any kind on top of the stack.
size
How many objects in me ?
top
Answer the first element of the stack without removing it.
I implement an element of a stack. I'm a container for any type of object, saved into the 'element' variable. My superclass Link allows me to be part of a LinkedList.
element
element:
Any kind of Object.
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
with: