IAQueue

A queue is a sequence with restricted access. It is an ordered collection of elements with no key and no element equality. The elements are arranged so that each collection has a first and a last element, each element except the last has a next element, and each element but the first has a previous element. The type and value of the elements are irrelevant, and have no effect on the behavior of the collection.

You can only add an element as the last element, and you can only remove the first element. Consequently, The elements of a queue are in chronological order.


IAQueue - Member Functions and Data by Group

Constructors & Destructor

You can construct and destruct objects of this class.


[view class]
~IAQueue
public:
~IAQueue()

Removes all elements from the collection. Destructors are called for all elements contained in the collection and for elements that have been constructed in advance.

Side Effects

All cursors of the collection become undefined.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IAQueue

You can construct and destruct objects of this class.


Overload 1
public:
IAQueue(INotifier&)

Use this constructor to create a collection with support for notification.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
protected:
IAQueue(IAQueue < Element > const&)

Constructs a collection. The collection is unbounded and is initially empty.
Note: The collection constructor does not define whether any elements are constructed when the collection is constructed. For some classes, the element's default constructor may be invoked when the collection's constructor is invoked. This happens if a tabular or a diluted sequence implementation variant is used for a collection. The element's default constructor is used to allocate the required storage and initialize the elements. Therefore, a default constructor must be available for elements in such cases.

Exception

IOutOfMemory

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 3
protected:
IAQueue()

The default constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Comparision

Use these members to compare a collection with a given collection.


[view class]
compare
public:
long compare( IAQueue < Element > const&, long ( * comparisonFunction ) ( Element const & , Element const & ) ) const

Compares the collection with the given collection. Comparison yields <0 if the collection is less than the given collection, 0 if the collection is equal to the given collection, and >0 if the collection is greater than the given collection. Comparison is defined by the first pair of corresponding elements, in both collections, that are not equal. If such a pair exists, the collection with the greater element is the greater one. Otherwise, the collection with more elements is the greater one.
Note:

  1. The given comparison function must return a result according to the following rules:
    >0
    if (element1 > element2)
    0
    if (element1 == element2)
    <0
    if (element1 < element2)
  2. For elements of type char*, compare() is not locale-sensitive by default. Because it uses strcmp() and not strcoll(), it compares the binary values representing the characters, and is not based on the LC_COLLATE category of the current locale. Its results are reliable only for code pages and character sets in which the collating sequence matches the sequence of binary representations. If you need a comparison based on the LC_COLLATE cateogory, then you must implement your own compare() function as described in Using Separate Functions in the Class Library User's Guide.

Return Value

Returns the result of the collection comparison.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Miscellaneous

Use these members to perform miscellaneous functions.


[view class]
addAsLast

Adds the element to the collection as the last element in sequential order. Sets the cursor to the added element.

Preconditions

Side Effects

All cursors of this collection, except the given cursor, become undefined.

Exceptions


Overload 1
public:
virtual void addAsLast(Element const&, ICursor&)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
virtual void addAsLast(Element const&)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
dequeue

Copies the first element of the collection to the given element, and removes it from the collection.

Precondition

The collection must not be empty.

Side Effects

All cursors of this collection become undefined.

Exception

IEmptyException


Overload 1
public:
virtual void dequeue()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
virtual void dequeue(Element&)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
enqueue

Adds the element to the collection, and sets the cursor to the added element. For ordinary queues, the given element is added as the last element. For priority queues, the element is added at a position determined by the ordering relation provided for the element or key type.

Preconditions

Side Effects

All cursors of this collection except the given cursor become undefined.

Exceptions


Overload 1
public:
virtual void enqueue(Element const&, ICursor&)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
virtual void enqueue(Element const&)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
removeFirst
public:
virtual void removeFirst()

Removes the first element from the collection. Element destructors are called as described in IACollection::removeAt.

Precondition

The collection must not be empty.

Side Effects

All cursors of this collection become undefined.

Exception

IEmptyException

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IAQueue - Inherited Member Functions and Data

Inherited Public Functions

IARestrictedAccessCollection

Inherited Public Data

Inherited Protected Functions

IACollectionBase
IARestrictedAccessCollection

Inherited Protected Data