9 #pragma warning(disable:4355) 39 void *
operator new (
size_t bytes);
42 void operator delete (
void *ptr);
100 template <
class T>
void 135 ::operator
delete (node);
142 template <
class T>
void 146 for (
size_t node_number = 0; node_number < n; ++node_number)
184 template <
class T>
size_t 216 ::std::unique_ptr <LQueueNode<T> > tail (
new LQueueNode<T> ());
229 template <
class T>
void 252 template <
class T>
void 297 template <
class T>
bool 309 template <
class T>
bool 313 return !(*
this == rhs);
319 template <
class T>
void 327 tail_->item_ = new_item;
336 catch (const ::std::bad_alloc&)
360 T item =
tail_->next_->item_;
397 return tail_->next_->item_;
411 template <
class T>
bool 419 template <
typename T>
428 template <
typename T>
437 template <
typename T>
446 template <
typename T>
454 template <
typename T> T &
460 template <
typename T>
const T &
466 template <
typename T>
477 template <
typename T>
491 template <
typename T>
bool 498 return (pos_ == rhs.
pos_);
501 template <
typename T>
bool 506 return !(*
this == rhs);
509 template <
typename T>
513 pos_ (queue.
tail_->next_)
517 for (pos = pos % (
queue_.count_ -1);
526 template <
typename T>
534 template <
typename T>
const T &
562 template <
typename T>
bool 570 template <
typename T>
bool 574 return !(*
this == rhs);
577 template <
typename T>
581 pos_ (queue.tail_->next_)
585 for (pos = pos % (
queue_.count_ -1);
594 template <
typename T>
Implements a forward iterator for LQueue type classes.
~LQueue(void)
Perform actions needed when queue goes out of scope.
void enqueue(const T &new_item)
Place a new_item at the tail of the queue.
LQueueIterator(LQueue< T > &queue, size_t pos=0)
Construct an LQueueIterator at position pos.
bool operator==(const LQueueConstIterator< T > &rhs) const
Equality operator.
LQueueNode< T > * next_
Pointer to the next node.
iterator end(void)
Get an iterator that points to the end of the queue.
T front(void) const
Returns the front queue item without removing it.
bool is_full(void) const
Returns 1 if the queue is full, otherwise returns 0.
const T & operator*(void) const
Dereference operator returns a const reference to the item contained at the current position...
LQueue< T > & operator=(const LQueue< T > &rhs)
Assignment operator.
LQueueConstIterator< T > const_iterator
bool operator!=(const LQueue< T > &s) const
Compare this queue with rhs for inequality such that *this>!=s is always the complement of the boolea...
Implements a forward iterator for LQueue type classes.
LQueueIterator< T > & operator++(void)
Preincrement operator.
iterator begin(void)
Get an iterator that points to the beginning of the queue.
T item_
Item in this node.
LQueueIterator< T > iterator
LQueue< T > & queue_
the queue we are dealing with
T & operator*(void)
Dereference operator returns a reference to the item contained at the current position.
static LQueueNode< T > * free_list_
Head of the free list, which is a stack of LQueueNodes used to speed up allocation.
static void free_list_allocate(size_t n)
Preallocate n LQueueNodes and store them on the free_list_.
void dequeue_i(void)
Remove the front item on the queue. Does not throw exceptions.
static void free_list_release(void)
Returns all dynamic memory on the free list to the free store.
const LQueue< T > & queue_
the queue we are dealing with
LQueueNode< T > * tail_
We only need to keep a single pointer for the circular linked list.
LQueueNode * next(void)
Return the next node to which this node points.
LQueueNode(void)
Default constructor that doesn't initialize item_.
void copy_list(const LQueue< T > &rhs)
bool operator!=(const LQueueIterator< T > &lhs) const
Nonequality operator.
bool operator==(const LQueue< T > &rhs) const
Compare this queue with rhs for equality.
T dequeue(void)
Remove and return the front item on the queue.
bool is_empty(void) const
Returns 1 if the queue is empty, otherwise returns 0.
bool operator==(const LQueueIterator< T > &rhs) const
Equality operator.
Defines a node in the LQueue that's implemented as a circular linked list.
Provides utility functions and classes for common tasks and needs.
size_t size(void) const
Returns the current number of elements in the queue.
Exception thrown by methods in this class when an underflow condition occurs.
Exception thrown by methods in this class when an overflow condition occurs.
const LQueueConstIterator< T > & operator++(void) const
Preincrement operator.
Copyright (c) 2015 Carnegie Mellon University.
Defines a generic "first-in/first-out" (FIFO) Abstract Data Type (ADT) using a circular linked list...
LQueue(size_t size_hint=0)
Constructor.
LQueueConstIterator(const LQueue< T > &queue, size_t pos=0)
Construct an LQueueIterator at position pos.
bool operator!=(const LQueueConstIterator< T > &lhs) const
Nonequality operator.
size_t count_
Number of items that are currently in the queue.