Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
drwnIndexQueue Class Reference

Provides a queue datastructure on a fixed number of indexes. At most one copy of each index can appear in the queue (a second enqueue is ignored). Membership of the queue can be queried. More...

Public Member Functions

 drwnIndexQueue ()
 default constructor of an empty queue
 
 drwnIndexQueue (size_t n)
 constructor takes the maximum number of indexes
 
 ~drwnIndexQueue ()
 destructor
 
bool empty () const
 returns true if the queue is empty
 
void clear ()
 clears the queue
 
void resize (size_t n)
 clears and resizes the queue
 
int front () const
 return the element at the front of the queue (or -1 if empty)
 
int back () const
 return the element at the back of the queue (or -1 if empty)
 
bool is_queued (int u) const
 returns true if u is in the queue
 
void push_back (int u)
 add u to the back of the queue
 
void push_front (int u)
 add u to the front of the queue
 
void pop_front ()
 remove the elelemt from the head of the queue
 
void erase (int u)
 remove u from the queue or do nothing if not in the queue
 

Protected Attributes

int _head
 
int _tail
 
vector< int > _rev
 
vector< int > _fwd
 

Static Protected Attributes

static const int TERMINAL = -1
 

Detailed Description

Provides a queue datastructure on a fixed number of indexes. At most one copy of each index can appear in the queue (a second enqueue is ignored). Membership of the queue can be queried.

Example usage:

q.push_back(10);
q.push_back(20);
q.push_back(10);
cout << q.front() << " is the head of the queue";
q.push_front(30);
cout << q.front() << " is the head of the queue";
q.erase(10);

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