MADARA  3.2.3
madara::utility::LQueue< T > Class Template Reference

Defines a generic "first-in/first-out" (FIFO) Abstract Data Type (ADT) using a circular linked list. More...

#include <LQueue.h>

Classes

class  Overflow
 Exception thrown by methods in this class when an overflow condition occurs. More...
 
class  Underflow
 Exception thrown by methods in this class when an underflow condition occurs. More...
 

Public Types

typedef LQueueConstIterator< T > const_iterator
 
typedef LQueueIterator< T > iterator
 
typedef T value_type
 

Public Member Functions

 LQueue (size_t size_hint=0)
 Constructor. More...
 
 LQueue (const LQueue< T > &rhs)
 Copy constructor. More...
 
 ~LQueue (void)
 Perform actions needed when queue goes out of scope. More...
 
iterator begin (void)
 Get an iterator that points to the beginning of the queue. More...
 
const_iterator begin (void) const
 Get a const iterator that points to the beginning of the queue. More...
 
dequeue (void)
 Remove and return the front item on the queue. More...
 
iterator end (void)
 Get an iterator that points to the end of the queue. More...
 
const_iterator end (void) const
 Get a const iterator that points to the end of the queue. More...
 
void enqueue (const T &new_item)
 Place a new_item at the tail of the queue. More...
 
front (void) const
 Returns the front queue item without removing it. More...
 
bool is_empty (void) const
 Returns 1 if the queue is empty, otherwise returns 0. More...
 
bool is_full (void) const
 Returns 1 if the queue is full, otherwise returns 0. More...
 
bool operator!= (const LQueue< T > &s) const
 Compare this queue with rhs for inequality such that *this>!=s is always the complement of the boolean return value of *this==s. More...
 
LQueue< T > & operator= (const LQueue< T > &rhs)
 Assignment operator. More...
 
bool operator== (const LQueue< T > &rhs) const
 Compare this queue with rhs for equality. More...
 
size_t size (void) const
 Returns the current number of elements in the queue. More...
 

Protected Member Functions

void copy_list (const LQueue< T > &rhs)
 
void delete_list (void)
 
void dequeue_i (void)
 Remove the front item on the queue. Does not throw exceptions. More...
 

Private Attributes

size_t count_
 Number of items that are currently in the queue. More...
 
LQueueNode< T > * tail_
 We only need to keep a single pointer for the circular linked list. More...
 

Friends

class LQueueConstIterator< T >
 
class LQueueIterator< T >
 

Detailed Description

template<class T>
class madara::utility::LQueue< T >

Defines a generic "first-in/first-out" (FIFO) Abstract Data Type (ADT) using a circular linked list.

This queue is a circular linked list where the tail_ pointer points to a dummy node which makes implementation much easier (particularly iterator traversal). When enqueuing an item, the dummy node contains the new item and points to a new dummy node. The head of the list is thsu always tail_->next_. Dequeuing an object gets rid of the head node and makes the dummy node point to the new head.

Definition at line 38 of file LQueue.h.

Member Typedef Documentation

template<class T>
typedef LQueueConstIterator<T> madara::utility::LQueue< T >::const_iterator

Definition at line 106 of file LQueue.h.

template<class T>
typedef LQueueIterator<T> madara::utility::LQueue< T >::iterator

Definition at line 105 of file LQueue.h.

template<class T>
typedef T madara::utility::LQueue< T >::value_type

Definition at line 44 of file LQueue.h.

Constructor & Destructor Documentation

template<class T >
madara::utility::LQueue< T >::LQueue ( size_t  size_hint = 0)

Constructor.

Definition at line 193 of file LQueue.cpp.

template<class T>
madara::utility::LQueue< T >::LQueue ( const LQueue< T > &  rhs)

Copy constructor.

Definition at line 208 of file LQueue.cpp.

template<class T >
madara::utility::LQueue< T >::~LQueue ( void  )

Perform actions needed when queue goes out of scope.

Definition at line 285 of file LQueue.cpp.

Member Function Documentation

template<typename T >
madara::utility::LQueue< T >::iterator madara::utility::LQueue< T >::begin ( void  )

Get an iterator that points to the beginning of the queue.

Definition at line 421 of file LQueue.cpp.

template<typename T >
madara::utility::LQueue< T >::const_iterator madara::utility::LQueue< T >::begin ( void  ) const

Get a const iterator that points to the beginning of the queue.

Definition at line 439 of file LQueue.cpp.

template<class T>
void madara::utility::LQueue< T >::copy_list ( const LQueue< T > &  rhs)
protected

Definition at line 230 of file LQueue.cpp.

template<class T >
void madara::utility::LQueue< T >::delete_list ( void  )
protected

Definition at line 253 of file LQueue.cpp.

template<class T >
T madara::utility::LQueue< T >::dequeue ( void  )

Remove and return the front item on the queue.

Throws the Underflow exception if the queue is empty.

Definition at line 349 of file LQueue.cpp.

template<class T >
void madara::utility::LQueue< T >::dequeue_i ( void  )
protected

Remove the front item on the queue. Does not throw exceptions.

Definition at line 370 of file LQueue.cpp.

template<typename T >
madara::utility::LQueue< T >::iterator madara::utility::LQueue< T >::end ( void  )

Get an iterator that points to the end of the queue.

Definition at line 430 of file LQueue.cpp.

template<typename T >
madara::utility::LQueue< T >::const_iterator madara::utility::LQueue< T >::end ( void  ) const

Get a const iterator that points to the end of the queue.

Definition at line 448 of file LQueue.cpp.

template<class T>
void madara::utility::LQueue< T >::enqueue ( const T &  new_item)

Place a new_item at the tail of the queue.

Throws the Overflow exception if the queue is full, e.g., if memory is exhausted.

Definition at line 320 of file LQueue.cpp.

template<class T >
T madara::utility::LQueue< T >::front ( void  ) const

Returns the front queue item without removing it.

Throws the Underflow exception if the queue is empty.

Definition at line 390 of file LQueue.cpp.

template<class T >
bool madara::utility::LQueue< T >::is_empty ( void  ) const

Returns 1 if the queue is empty, otherwise returns 0.

Definition at line 404 of file LQueue.cpp.

template<class T >
bool madara::utility::LQueue< T >::is_full ( void  ) const

Returns 1 if the queue is full, otherwise returns 0.

Definition at line 412 of file LQueue.cpp.

template<class T>
bool madara::utility::LQueue< T >::operator!= ( const LQueue< T > &  s) const

Compare this queue with rhs for inequality such that *this>!=s is always the complement of the boolean return value of *this==s.

Definition at line 310 of file LQueue.cpp.

template<class T>
madara::utility::LQueue< T > & madara::utility::LQueue< T >::operator= ( const LQueue< T > &  rhs)

Assignment operator.

Definition at line 266 of file LQueue.cpp.

template<class T>
bool madara::utility::LQueue< T >::operator== ( const LQueue< T > &  rhs) const

Compare this queue with rhs for equality.

Returns true if the sizes of the two queues are equal and all the elements from 0 .. size() are equal, else false.

Definition at line 298 of file LQueue.cpp.

template<class T >
size_t madara::utility::LQueue< T >::size ( void  ) const

Returns the current number of elements in the queue.

Definition at line 185 of file LQueue.cpp.

Friends And Related Function Documentation

template<class T>
friend class LQueueConstIterator< T >
friend

Definition at line 41 of file LQueue.h.

template<class T>
friend class LQueueIterator< T >
friend

Definition at line 40 of file LQueue.h.

Member Data Documentation

template<class T>
size_t madara::utility::LQueue< T >::count_
private

Number of items that are currently in the queue.

Definition at line 138 of file LQueue.h.

template<class T>
LQueueNode<T>* madara::utility::LQueue< T >::tail_
private

We only need to keep a single pointer for the circular linked list.

This points to the tail of the queue. Since the list is circular, the head of the queue is always tail_->next_.

Definition at line 135 of file LQueue.h.


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