OMQueue class

The OMQueue class contains basic library functions that enable you to create and manipulate OMQueues. An OMQueue is a type-safe, dynamically sized queue. It is implemented on a cyclic array, and implements a FIFO (first in, first out) algorithm. An OMQueue is implemented with OMCollection.

This class is defined in the header file omqueue.h.

Attributes and collections
m_grow - specifies whether the queue size can be enlarged
m_head - specifies the head of the queue
m_myQueue - specifies the queue implementation
m_tail - specifies the tail of the queue
Construction summary
OMQueue
Constructs an OMQueue object
~OMQueue
Destroys the OMQueue object
Method summary
get
Gets the current element in the queue
getCount
Gets the number of elements in the queue
getInverseQueue
Returns the element that will be returned by get() in the tail of the queue
getQueue
Returns the element that will be returned by get() in the head of the queue
getSize
Returns the size of the memory allocated for the queue
increaseHead_
Increases the size of the queue head
increaseTail_
Increases the size of the queue tail
isEmpty
Determines whether the queue is empty
isFull
Determines whether the queue is full
put
Adds an element to the queue
Attributes and collections

m_grow

This Boolean attribute specifies whether the queue size can be enlarged. It is defined as follows:
OMBoolean m_grow;

m_head

This attribute specifies the head of the queue. It is defined as follows:
int m_head;

m_myQueue

This collection specifies the queue implementation. OMQueue is implemented as a cyclic array.

It is defined as follows:
OMCollection<Concept> m_myQueue;

m_tail

This attribute specifies the tail of the queue. It is defined as follows:
int m_tail;

Example

Consider a class, Graph, that has a bfs() operation that performs BFS search on the graph nodes to find a node with the specified data. The following figure shows the OMD of the Graph class.

The following figure shows the browser view of the Graph class.

The bfs() implementation uses OMQueue as the search container and OMMap as a record of the visited elements.

The following figure shows the implementation of Graph::bfs().

The following figure shows the implementation of Graph::Node::addAggregates().


Feedback