OLQueue Class Reference
[Containers]

A first-in-first-out collection. More...

#import <ObjectiveLib/Queue.h>

Inheritance diagram for OLQueue:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(id) - back
 Return the last item.
(int) - compare:
 Compare this queue to another object.
(id) - copy
 Make a copy of this queue.
(BOOL) - empty
 Test whether the queue is empty.
(id) - front
 Return the least recently added item.
(BOOL) - isEqual:
 Return whether this queue is equal to another one.
(void) - pop
 Remove the item at the front of the queue.
(void) - push:
 Add an item to the back of the queue.
(unsigned) - size
 Return the number of elements in the queue.
(void) - writeSelfToStream:
 Write the object to a stream.
Initializers and Deallocators
(id) - free
 Finalize the queue and deallocate any allocated memory.
(id) - init
 Initialize the queue.
(id) - initWithObjectInStream:
 Initialize the object.
(id) - initWithQueue:
 Initialize the queue.

Static Public Member Functions

(id) + queue
 Create and return a new queue.
(id) + queueWithQueue:
 Create and return a new queue.

Protected Attributes

OLDequedeque
 The container that provides the underlying data structure.

Detailed Description

A first-in-first-out collection.

Elements may be added to the back of the queue and removed from the front. The element at the back (OLQueue) of the queue is the one added most recently, while the element at the front (OLQueue) is the one added least recently. The queue class just provides a restricted view of the underlying container OLDeque for occasions when only the simple functionality of a FIFO collection is required. It is not a true container because it does not provide iterators, so it cannot be used with generic algorithms.

See also:
OLDeque, OLStack


Member Function Documentation

- (id) back  

Return the last item.

The most recently added element is returned.

Note:
The behavior of this message is undefined if the queue is empty.
Returns:
the most recently added item

- (int) compare: (id)  other  

Compare this queue to another object.

If the other object is of type OLQueue, the underlying deque of this object will compared to the underlying deque of other using the compare: (OLDeque) method.

Parameters:
other the object with which to compare this one
Returns:
a value greater than, equal to, or less than zero accoringly as this object is greater than, equal to, or less than other

- (id) copy  

Make a copy of this queue.

Returns:
the copy

- (BOOL) empty  

Test whether the queue is empty.

Returns:
YES if the queue is empty, NO otherwise

- (id) free  

Finalize the queue and deallocate any allocated memory.

- (id) front  

Return the least recently added item.

The element at the front of the queue is the one that will be removed by the message pop.

Note:
The behavior of this message is undefined if the queue is empty.
Returns:
the least recently added item

- (id) init  

Initialize the queue.

The queue is initially empty.

Returns:
a reference to this queue

- (id) initWithObjectInStream: (OLObjectInStream *)  stream  

Initialize the object.

Each instance variable is read from stream and all other initialization is performed.

Parameters:
stream the stream from which to read
Returns:
a reference to this object

Reimplemented from < OLStreamable >.

- (id) initWithQueue: (OLQueue *)  queue  

Initialize the queue.

All objects are copied from queue into this queue.

Parameters:
queue the queue that should be copied
Returns:
a reference to this queue

- (BOOL) isEqual: (id)  object  

Return whether this queue is equal to another one.

Two queues 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.

Parameters:
object the object to test
Returns:
YES if object is equal to this queue

- (void) pop  

Remove the item at the front of the queue.

The element returned by the message front is removed from the queue.

Precondition:
The queue cannot be empty.

- (void) push: (id)  object  

Add an item to the back of the queue.

The element object will be added to the back of the queue and can be accessed with the message back.

Parameters:
object the element to add

+ (id) queue  

Create and return a new queue.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Returns:
a new queue

+ (id) queueWithQueue: (OLQueue *)  right  

Create and return a new queue.

The queue is initialized with the contents of right.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
right the queue to copy into the new one
Returns:
a new queue

- (unsigned) size  

Return the number of elements in the queue.

Returns:
the number of elements

- (void) writeSelfToStream: (OLObjectOutStream *)  stream  

Write the object to a stream.

All instance variables are written to stream.

Parameters:
stream the stream to which to write.

Reimplemented from < OLStreamable >.


Member Data Documentation

- (OLDeque*) deque [protected]

The container that provides the underlying data structure.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:18:59 2007, © 2004-2007 Will Mason
SourceForge.net Logo