ObjectiveLib  1.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes
OLQueue Class Reference

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) - copyWithZone:
 Make a copy of this queue allocating memory from the given zone.
(BOOL) - empty
 Test whether the queue is empty.
(void) - encodeWithCoder:
 Encode the queue.
(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) - init
 Initialize the queue.
(id) - initWithCoder:
 Initialize the queue.
(id) - initWithObjectInStream:
 Initialize the object.
(id) - initWithQueue:
 Initialize the queue.
(void) - dealloc
 Finalize the queue and deallocate any allocated memory.

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:
otherthe 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) copyWithZone: (NSZone *)  zone

Make a copy of this queue allocating memory from the given zone.

Parameters:
zonethe zone from which to allocate memory
Returns:
the copy
- (void) dealloc

Finalize the queue and deallocate any allocated memory.

- (BOOL) empty

Test whether the queue is empty.

Returns:
YES if the queue is empty, NO otherwise
- (void) encodeWithCoder: (NSCoder *)  encoder

Encode the queue.

The queue is saved to an archive using encoder. The queue will be retrieved from the archive using the initializer initWithCoder:.

Parameters:
encoderthe coder which will save the bit queue to the archive
- (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) initWithCoder: (NSCoder *)  decoder

Initialize the queue.

This initializer creates a new queue from an archive and returns it.

Postcondition:
The queue returned will be identical to the queue saved to the archive using the encodeWithCoder: message.
Parameters:
decoderthe coder which will decode the archived queue
Returns:
a reference to this queue

Initialize the object.

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

Parameters:
streamthe 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:
queuethe 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:
objectthe 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:
objectthe 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:
rightthe 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:
streamthe 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 Sat Feb 15 2014 07:45:35, © 2004-2007 Will Mason