- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Containers::DynamicQueue Class Reference

`#include <DynamicQueue.h>`

Inheritance diagram for Mers::Utils::Containers::DynamicQueue:

[legend]
Collaboration diagram for Mers::Utils::Containers::DynamicQueue:

[legend]
List of all members.

## Public Member Functions
| DynamicQueue (DynamicArray::DynamicArrayType queueType, bool myOwnershipStatus, int myMaxQueueSize=-1)
virtual | ~DynamicQueue ()
virtual unsigned int | getLength () const
virtual bool | isEmpty () const
virtual void | printArray (std::ostream &out, char const *seperator) const
## Protected Member Functions
| DynamicQueue (DynamicQueue const &other)
| DynamicQueue (DynamicQueue const *other)
int | enqueue (void *element)
int | dequeue (void *&element)
int | peekQueue (void *&element)
## Protected Attributes
unsigned int | head
| the head of the queue
unsigned int | tail
| the tail of the queue
int | maxQueueSize

## Detailed Description

A typical queue, but dynamically resized to fit the data. This queue will never shrink, just grow. It's implemented as a wrap around queue, which means insertion and deletion is O(1).

Definition at line 32 of file DynamicQueue.h.

## Constructor & Destructor Documentation

DynamicQueue::DynamicQueue | ( | DynamicArray::DynamicArrayType | queueType,
|  | bool | myOwnershipStatus,
|  | int | myMaxQueueSize = `-1` |
| ) |  |  |

creates a new, empty queue.

Parameters:

  | queueType | the type of this queue
  | myOwnershipStatus | the ownership status. If true, this object owns the array objects it contains and should delete them upon being deleted.
  | myMaxQueueSize | a positive value limits the queue to having at most myMaxQueueSize elements. The queue will be resized to hold myMaxQueueSize elements. If a negative value is specified, the queue will grow to fit the number of inserted elements as space permits.

Definition at line 27 of file DynamicQueue.cpp.

References head, maxQueueSize, Mers::Utils::Containers::DynamicArray::resize(), and tail.

Here is the call graph for this function:

DynamicQueue::~DynamicQueue | ( |  | ) | `[virtual]`

destroys this queue

Definition at line 47 of file DynamicQueue.cpp.

DynamicQueue::DynamicQueue | ( | DynamicQueue const & | other | ) | `[protected]`

Creates a new queue with a copy of the contents from the other queue. This can be an expensive operation.

Parameters:

  | other | the queue whos contents are copied

Definition at line 91 of file DynamicQueue.cpp.

References head, and tail.

DynamicQueue::DynamicQueue | ( | DynamicQueue const * | other | ) | `[protected]`

Creates a new queue with a copy of the contents from the other queue. This can be an expensive operation.

Parameters:

  | other | the queue whos contents are copied

Definition at line 100 of file DynamicQueue.cpp.

References head, and tail.

## Member Function Documentation

unsigned int DynamicQueue::getLength | ( |  | ) | const`[virtual]`

Returns the current length of the queue (number of elements in it).

Returns:
  the number of elements in the queue

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 53 of file DynamicQueue.cpp.

References head, Mers::Utils::Containers::DynamicArray::mSize, and tail.

Referenced by enqueue().

bool DynamicQueue::isEmpty | ( |  | ) | const`[virtual]`

Returns true if a call to getLength() would return 0.

Returns:
  true if the array length is currently 0

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 62 of file DynamicQueue.cpp.

References head, and tail.

void DynamicQueue::printArray | ( | std::ostream & | out,
|  | char const * | seperator |
| ) |  |  | const`[virtual]`

Prints out the Dynamic Queue as a sequence of elements. It sperates each element with seperator. each element is printed by calling printElement().

Parameters:

  | out | the ostream being written to
  | seperator | the seperator used between each element

Definition at line 71 of file DynamicQueue.cpp.

References Mers::Utils::Containers::DynamicArray::array, head, Mers::Utils::Containers::DynamicArray::mSize, Mers::Utils::Containers::DynamicArray::printElement(), and tail.

Here is the call graph for this function:

int DynamicQueue::enqueue | ( | void * | element | ) | `[protected]`

Adds the specified element to the end of the queue, adding space as necessary.

Parameters:

  | element | the element being added to the queue

Returns:
  0 on success or a positive number if the queue could not be resized

Definition at line 109 of file DynamicQueue.cpp.

References Mers::Utils::Containers::DynamicArray::array, getLength(), head, maxQueueSize, Mers::Utils::Containers::DynamicArray::mSize, Mers::Utils::Containers::DynamicArray::resize(), and tail.

Referenced by Mers::Utils::Containers::ObjectQueue::enqueue().

Here is the call graph for this function:

int DynamicQueue::dequeue | ( | void *& | element | ) | `[protected]`

Returns the element at the beginning of the queue and removes it from the queue.

Parameters:

  | element | the first element is returned here

Returns:
  0 on success, a positive number if the queue was empty. This also sets element to NULL

Definition at line 167 of file DynamicQueue.cpp.

References Mers::Utils::Containers::DynamicArray::array, head, Mers::Utils::Containers::DynamicArray::mSize, and tail.

Referenced by Mers::Utils::Containers::ObjectQueue::dequeue().

int DynamicQueue::peekQueue | ( | void *& | element | ) | `[protected]`

Returns the element at the beginning of the queue but does not remove it from the queue.

Parameters:

  | element | the first element is returned here

Returns:
  0 on success, a positive number if the queue was empty. This also sets element to NULL

Definition at line 185 of file DynamicQueue.cpp.

References Mers::Utils::Containers::DynamicArray::array, head, and tail.

Referenced by Mers::Utils::Containers::ObjectQueue::peekQueue().

## Member Data Documentation

int Mers::Utils::Containers::DynamicQueue::maxQueueSize`[protected]`

the maximum queue size, or -1 if the queue is unbounded. This is checked at each insertion

Definition at line 162 of file DynamicQueue.h.

Referenced by DynamicQueue(), and enqueue().

The documentation for this class was generated from the following files:

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/DynamicQueue.h
- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/DynamicQueue.cpp