- Inherits From:
- Declared In:
This datastructure does not implement the copying and coding protocols as stacks are usually required in the context of algorithms, rather than data storage.
storage All instance variables are private.
- + stack
- + stackWithObject:
- - init
- - initWithObject:
Querying the stack
- - pushObject:
- - popObject
- - clear
- - topObject
- - topObjects:
- - count
+ (EDStack *)stack
Creates and returns an empty stack.
+ (EDStack *)stackWithObject:(id)anObject
Creates and returns a stack with a single object on it.
Removes all objects from the stack. Each removed object is sent a release message.
- (unsigned int)count
Returns the number of objects on the stack.
Initialises a newly allocated stack.
Initialises a newly allocated stack by adding anObject to it. The object receives a retain message.
Removes and returns the topmost object from the stack. The object receives a release message. If the stack is empty this method returns
Pushes anObject onto the stack. The object receives a retain message.
Returns the topmost object on the stack, or
nil if the stack is empty.
- (NSArray *)topObjects:(int)count
Returns an array containing the n topmost object on the stack. Raises an exception if n is greater than the value returned by count.