#import <ObjectiveLib/Stack.h>
Inheritance diagram for OLStack:
Public Member Functions | |
(int) | - compare: |
Compare this stack to another object. | |
(id) | - copy |
Make a copy of this stack. | |
(BOOL) | - empty |
Test whether the stack is empty. | |
(BOOL) | - isEqual: |
Return whether this stack is equal to another one. | |
(void) | - pop |
Remove the item at the top of the stack. | |
(void) | - push: |
Add an item to the top of the stack. | |
(unsigned) | - size |
Return the number of elements in the stack. | |
(id) | - top |
Return the element at the top of the stack. | |
(void) | - writeSelfToStream: |
Write the object to a stream. | |
Initializers and Deallocators | |
(id) | - free |
Finalize the stack and deallocate any allocated memory. | |
(id) | - init |
Initialize the stack. | |
(id) | - initWithObjectInStream: |
Initialize the object. | |
(id) | - initWithStack: |
Initialize the stack. | |
Static Public Member Functions | |
(id) | + stack |
Create and return a new stack. | |
(id) | + stackWithStack: |
Create and return a new stack. | |
Protected Attributes | |
OLDeque * | deque |
The container that provides the underlying data structure. |
Elements are added to and removed from the top of a stack. Access is provided to the top (OLStack) element of the stack, which is also the most recently added item. The stack class just provides a restricted view of the underlying container OLDeque for occasions when only the simple functionality of a FILO collection is required. It is not a true container because it does not provide iterators, so it cannot be used with generic algorithms.
- (int) compare: | (id) | other |
Compare this stack to another object.
If the other object is of type OLStack, each of the contained objects is compared to the corresponding object in other by calling the compare:
method.
other | the object with which to compare this one |
- (id) copy |
Make a copy of this stack.
- (BOOL) empty |
Test whether the stack is empty.
- (id) free |
Finalize the stack and deallocate any allocated memory.
- (id) init |
Initialize the stack.
The stack is initially empty.
- (id) initWithObjectInStream: | (OLObjectInStream *) | stream |
Initialize the object.
Each instance variable is read from stream and all other initialization is performed.
stream | the stream from which to read |
Reimplemented from < OLStreamable >.
- (id) initWithStack: | (OLStack *) | stack |
Initialize the stack.
All objects are copied from stack into this stack.
stack | the stack that should be copied |
- (BOOL) isEqual: | (id) | object |
Return whether this stack is equal to another one.
Two stacks are considered equal if they both contain the same number of objects that all return YES to the message isEqual:
and they are in the same order.
object | the object to test |
- (void) pop |
Remove the item at the top of the stack.
The element returned by the message top is removed from the stack.
- (void) push: | (id) | object |
Add an item to the top of the stack.
The element object will be added to the top of the stack and can be accessed with the message top.
object | the element to add |
- (unsigned) size |
Return the number of elements in the stack.
+ (id) stack |
Create and return a new stack.
+ (id) stackWithStack: | (OLStack *) | right |
Create and return a new stack.
The stack is initialized with the contents of right.
right | the stack to copy into the new one |
- (id) top |
Return the element at the top of the stack.
The element returned is the one removed by the message pop and is also the most recently added element.
- (void) writeSelfToStream: | (OLObjectOutStream *) | stream |
Write the object to a stream.
All instance variables are written to stream.
stream | the stream to which to write. |
Reimplemented from < OLStreamable >.
|