- Inherits From:
- NSObject
- Declared In:
- EDStack.h
This datastructure does not implement the copying and coding protocols as stacks are usually required in the context of algorithms, rather than data storage.
NSMutableArray *storage;
storage All instance variables are private.
Creating stacksAdding/removing objects
- + 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.
- (void)clear
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.
- (id)init
Initialises a newly allocated stack.
- (id)initWithObject:(id)anObject
Initialises a newly allocated stack by adding anObject to it. The object receives a retain message.
- (id)popObject
Removes and returns the topmost object from the stack. The object receives a release message. If the stack is empty this method returns nil.
- (void)pushObject:(id)anObject
Pushes anObject onto the stack. The object receives a retain message.
- (id)topObject
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.