Class: TPriorityQueueOf

Declaration: PriorityQueueOf.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TCollectionOf

Inherited By:

None.

Purpose:

TPriorityQueueOf is a template class that you can use to create a collection of objects that are partially ordered, based on an ordering function that you can specify. Due to the partially ordered nature of TPriorityQueueOf, when iterators are used on these collections they do not return objects in order. The collection automatically grows in size, as needed, when objects are added.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Do not derive classes from TPriorityQueueOf.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Other Considerations:

None.

Member Function: TPriorityQueueOf::Insert

void Insert (const AType * obj)

Interface Category:

API.

Purpose:

Adds an object into the collection, automatically growing the size of the collection, if necessary.

Calling Context:

Call this function directly to add an object to the collection when a return value is not required.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPriorityQueueOf::Pop

AType * Pop ()

Interface Category:

API.

Purpose:

Removes the object with the highest priority from the queue.

Calling Context:

Call this function directly to remove the highest priority object from the queue and obtain a reference to the object.

Parameters:

Return Value:

A reference to the object removed. If the collection is empty, a NIL reference is returned.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If there are several objects with the highest priority, only one will be removed and returned.

Member Function: TPriorityQueueOf::Peek

AType * Peek () const

Interface Category:

API.

Purpose:

Returns a reference to the object in the collection with the highest priority without removing the object.

Calling Context:

Call this function directly to obtain a reference to the highest priority object.

Parameters:

Return Value:

A reference to the highest priority object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If there are several objects with the highest priority, only one reference will be returned.

Member Function: TPriorityQueueOf::Replace

AType * Replace (const AType * obj)

Interface Category:

API.

Purpose:

This operator does two things. First, it removes the highest priority object from the collection and then adds the object you have passed to the collection.

Calling Context:

Call this function directly to remove the highest priority object and to add another object to the collection.

Parameters:

Return Value:

A reference to the object removed from the collection.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Note that, due to the order of the operations, it is possible for the object that you are adding to the collection to have a higher priority than the object that is removed from the collection. is removed .

Member Function: TPriorityQueueOf::operator!=

bool operator != (const TPriorityQueueOf < AType > & priorityQueueOf) const

Interface Category:

API.

Purpose:

Tests whether the contents of this collection differ from those of the argument.

Calling Context:

Call this function directly to test the equivalence of the objects on either side of the != symbol.

Parameters:

Return Value:

Returns true if the contents of this object and the other object are not equivalent.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPriorityQueueOf::operator==

bool operator ==(const TPriorityQueueOf < AType > & priorityQueueOf) const

Interface Category:

API.

Purpose:

Tests whether the contents of this collection are equivalent to those of the argument.

Calling Context:

Call this function directly to test the equivalence of the objects on either side of the ==symbol.

Parameters:

Return Value:

Returns true if if the contents of this object and the other object are equivalent.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPriorityQueueOf::operator=

const TPriorityQueueOf < AType > & operator =(const TPriorityQueueOf < AType > &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function directly when one object is assigned to another compatible object.

Parameters:

Return Value:

A reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPriorityQueueOf::~TPriorityQueueOf

virtual ~ TPriorityQueueOf ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Call this function directly to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPriorityQueueOf::TPriorityQueueOf

  1. TPriorityQueueOf ()
  2. TPriorityQueueOf (const TPriorityQueueOf < AType > & that)
  3. TPriorityQueueOf (TComparator < AType > * adoptedComparator, TStreamer < AType > * adoptedStreamer)

Interface Category:

API.

Purpose:

  1. Default constructor. Creates an empty collection.
  2. Copy constructor.
  3. Creates an empty collection with the specified comparator and streamer.

Calling Context:

  1. Call this function directly anywhere the creation of an empty TPriorityQueueOf is desired.
  2. Call this function directly to copy a collection.
  3. Call this function directly to create an empty collection with the specified comparator and streamer.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.