#import <ObjectiveLib/Deque.h>
Inheritance diagram for OLDeque:
Public Member Functions | |
(void) | - assign:filledWith: |
Assign objects to the deque. | |
(void) | - assignAt:value: |
Assign object to the position at index. | |
(void) | - assignFrom:to: |
Assign a range of objects to the deque. | |
(id) | - at: |
Return the object at index. | |
(id) | - back |
Return the last object in the deque. | |
(OLDequeIterator *) | - begin |
Return an iterator pointing to the beginning of the sequence. | |
(void) | - clear |
Remove all elements. | |
(int) | - compare: |
Compare this deque to another object. | |
(id) | - copy |
Make a copy of this deque. | |
(BOOL) | - empty |
Test whether the deque is empty. | |
(OLDequeIterator *) | - end |
Return an iterator pointing to one position beyond the end of the sequence. | |
(OLDequeIterator *) | - erase: |
Remove the element designated by where. | |
(OLDequeIterator *) | - eraseFrom:to: |
Remove a range of elements. | |
(id) | - front |
Return the first object in the deque. | |
(void) | - insertAt:count:filledWith: |
Insert a number of objects into the deque. | |
(void) | - insertAt:from:to: |
Insert a range of objects into the deque. | |
(OLDequeIterator *) | - insertAt:value: |
Insert an object into the deque. | |
(BOOL) | - isEqual: |
Return whether this deque is equal to another one. | |
(unsigned) | - maxSize |
Return the maxiumum number of objects that can be stored in a deque. | |
(void) | - popBack |
Remove the last element in the deque. | |
(void) | - popFront |
Remove the first element in the deque. | |
(void) | - pushBack: |
Insert object at the end of the sequence. | |
(void) | - pushFront: |
Insert object at the beginning of the sequence. | |
(OLReverseRandomIterator *) | - rbegin |
Return a reverse iterator pointing to the end of the sequence. | |
(OLReverseRandomIterator *) | - rend |
Return a reverse iterator pointing to the beginning of the sequence. | |
(void) | - resize:filledWith: |
Resize the deque to newsize. | |
(unsigned) | - size |
Return the number of elements in the deque. | |
(void) | - swap: |
Swap this deque with another one. | |
(void) | - writeSelfToStream: |
Write the object to a stream. | |
Initializers and Deallocators | |
(id) | - free |
Finalize the deque and deallocate any allocated memory. | |
(id) | - init |
Initialize the deque. | |
(id) | - initFrom:to: |
Initialize the deque. | |
(id) | - initWithDeque: |
Initialize the deque. | |
(id) | - initWithObjectInStream: |
Initialize the object. | |
(id) | - initWithSize:filledWith: |
Initialize the deque. | |
Static Public Member Functions | |
(id) | + deque |
Create and return a new deque. | |
(id) | + dequeFrom:to: |
Create and return a new deque. | |
(id) | + dequeWithDeque: |
Create and return a new deque. | |
(id) | + dequeWithSize:filledWith: |
Create and return a new deque. | |
Protected Attributes | |
OLDequeIterator * | finish |
The end of the sequence. | |
id ** | map |
The map of deque nodes. | |
unsigned | mapSize |
The number of nodes. | |
OLDequeIterator * | start |
The beginning of the sequence. |
A double-ended queue is similar to a vector or array, except that its storage is additionally optimized for insertion and removal from the beginning of the sequence as well as from the end. It provides random access to its elements. It also serves as a suitable container for use by OLBackInsertIterator, OLFrontInsertIterator and OLInsertIterator.
- (void) assign: | (unsigned) | count | ||
filledWith: | (id) | value | ||
Assign objects to the deque.
The current contents of the deque are removed, and the deque is filled with count elements of value.
count | the number of elements to assign | |
value | the object to be copied into the deque |
- (void) assignAt: | (unsigned) | index | ||
value: | (id) | object | ||
Assign object to the position at index.
The object currently in possession of the position at index is removed and replaced with object.
index | the index to which to assign | |
object | the object to put at index |
- (void) assignFrom: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Assign a range of objects to the deque.
The current contents of the deque are removed, and all elements in the range [first, last)
are inserted into the deque.
first | the first in the range of objects to assign | |
last | one beyond the last in the range of objects to assign |
- (id) at: | (unsigned) | index |
Return the object at index.
A reference to the object is returned, though the deque still owns the object in question.
index | the index of the object to look up |
- (id) back |
Return the last object in the deque.
A reference to the object is returned, though the deque still owns the object in question.
- (OLDequeIterator*) begin |
Return an iterator pointing to the beginning of the sequence.
- (void) clear |
Remove all elements.
- (int) compare: | (id) | other |
Compare this deque to another object.
If the other object is of type OLDeque, 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 deque.
+ (id) deque |
Create and return a new deque.
The deque is empty.
+ (id) dequeFrom: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Create and return a new deque.
The deque is initialized with the contents of the range [first, last)
.
first | the first in the range of elements to insert | |
last | one beyond the last in the range of elements to insert |
+ (id) dequeWithDeque: | (OLDeque *) | right |
Create and return a new deque.
The deque is initialized with the contents of right.
right | the deque with which to initialize the new one |
+ (id) dequeWithSize: | (unsigned) | size | ||
filledWith: | (id) | value | ||
Create and return a new deque.
The deque is initialized with a size of size and is filled with value.
size | the number of elements to insert | |
value | the object to be copied |
- (BOOL) empty |
Test whether the deque is empty.
- (OLDequeIterator*) end |
Return an iterator pointing to one position beyond the end of the sequence.
- (OLDequeIterator*) erase: | (OLDequeIterator *) | where |
Remove the element designated by where.
where | an iterator designating the element to remove |
- (OLDequeIterator*) eraseFrom: | (OLDequeIterator *) | first | ||
to: | (OLDequeIterator *) | last | ||
Remove a range of elements.
All elements in the range [first, last)
will be removed from the deque.
first | the first in the range of elements to remove | |
last | one position beyond the last in the range of elements to remove |
- (id) free |
Finalize the deque and deallocate any allocated memory.
- (id) front |
Return the first object in the deque.
A reference to the object is returned, though the deque still owns the object in question.
- (id) init |
Initialize the deque.
The deque begins life empty.
- (id) initFrom: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Initialize the deque.
The deque inserts all elements referred to in the range [first, last)
.
first | the first in the range of elements to insert | |
last | one beyond the last in the range of elements to insert |
- (id) initWithDeque: | (OLDeque *) | deque |
Initialize the deque.
The deque is initialized with the contents of the give deque.
deque | the deque to copy |
- (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) initWithSize: | (unsigned) | count | ||
filledWith: | (id) | value | ||
Initialize the deque.
The initial size of the deque will be count, and value will be copied into the deque count times.
count | the number of elements to insert | |
value | the object to be copied |
- (void) insertAt: | (OLDequeIterator *) | where | ||
count: | (unsigned) | num | ||
filledWith: | (id) | value | ||
Insert a number of objects into the deque.
num objects of value will be inserted just before the position referred to by where. Thus, it is valid to use an iterator returned by end as an argument.
where | the position at which to insert the objects | |
num | the number of objects to insert | |
value | the object to be copied into the deque |
- (void) insertAt: | (OLDequeIterator *) | where | ||
from: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Insert a range of objects into the deque.
All objects in the range [first, last)
are inserted just before the position referred to by where. Thus, it is valid to use an iterator returned by end as an argument.
where | the position at which to insert the objects | |
first | the first in the range of objects to insert | |
last | one position beyond the last in the range of objects to insert |
- (OLDequeIterator*) insertAt: | (OLDequeIterator *) | where | ||
value: | (id) | object | ||
Insert an object into the deque.
The object will be inserted just before the position referred to by where. Thus, it is valid to use an iterator returned by end as an argument.
where | the position at which to insert object | |
object | the object to insert |
- (BOOL) isEqual: | (id) | object |
Return whether this deque is equal to another one.
Two deques 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 |
Reimplemented from < OLBackInserter >.
- (unsigned) maxSize |
Return the maxiumum number of objects that can be stored in a deque.
This limit is theoretical, meaning that there is no guarantee that you can insert this many objects into any given deque. The memory conditions of the run-time system play an important role.
- (void) popBack |
Remove the last element in the deque.
- (void) popFront |
Remove the first element in the deque.
- (void) pushBack: | (id) | object |
Insert object at the end of the sequence.
object | the object to insert |
Reimplemented from < OLBackInserter >.
- (void) pushFront: | (id) | object |
Insert object at the beginning of the sequence.
object | the object to insert |
Reimplemented from < OLFrontInserter >.
- (OLReverseRandomIterator*) rbegin |
Return a reverse iterator pointing to the end of the sequence.
Advancing the returned iterator will move backwards through the sequence to the point indicated by the iterator returned by rend.
- (OLReverseRandomIterator*) rend |
Return a reverse iterator pointing to the beginning of the sequence.
This iterator indicates one position beyond the last position that may be referenced by a reverse iterator.
- (void) resize: | (unsigned) | newsize | ||
filledWith: | (id) | value | ||
Resize the deque to newsize.
If newsize is smaller than the current size, then the sequence will be truncated. If newsize is larger than the current size, then value will be inserted at the end of the deque as many times as necessary to fill the new size.
newsize | the new size of the deque | |
value | the value with which to fill new elements, if necessary |
- (unsigned) size |
Return the number of elements in the deque.
- (void) swap: | (OLDeque *) | right |
Swap this deque with another one.
All elements in right will be placed into this deque, and all elements in this deque will be placed in right.
right | the deque with which to swap this one |
- (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 >.
- (OLDequeIterator*) finish [protected] |
The end of the sequence.
- (id**) map [protected] |
The map of deque nodes.
- (unsigned) mapSize [protected] |
The number of nodes.
- (OLDequeIterator*) start [protected] |
The beginning of the sequence.
|