10 #pragma warning(disable : 4355)
41 void*
operator new(
size_t bytes);
44 void operator delete(
void* ptr);
131 ::operator
delete(node);
142 for (
size_t node_number = 0; node_number < n; ++node_number)
158 : item_(item), next_(next)
187 : tail_(0), count_(0)
201 : tail_(0), count_(0)
233 ::std::swap(tail_, temp.
tail_);
236 ::std::swap(count_, temp.
count_);
288 return (size() == rhs.
size()) && ::std::equal(begin(), end(), rhs.
begin());
299 return !(*
this == rhs);
313 tail_->item_ = new_item;
317 tail_ = tail_->next_;
322 catch (const ::std::bad_alloc&)
346 T item = tail_->next_->item_;
361 tail_->next_ = head->
next_;
381 return tail_->next_->item_;
481 return (pos_ == rhs.
pos_);
489 return !(*
this == rhs);
495 : queue_(queue), pos_(queue.tail_->next_)
499 for (pos = pos % (
queue_.count_ - 1); pos > 0; --pos)
509 : queue_(queue), pos_(pos)
548 return (pos_ == rhs.
pos_);
555 return !(*
this == rhs);
561 : queue_(queue), pos_(queue.tail_->next_)
565 for (pos = pos % (
queue_.count_ - 1); pos > 0; --pos)
575 : queue_(queue), pos_(pos)
Implements a forward iterator for LQueue type classes.
const LQueueConstIterator< T > & operator++(void) const
Preincrement operator.
const T & operator*(void) const
Dereference operator returns a const reference to the item contained at the current position.
const LQueue< T > & queue_
the queue we are dealing with
LQueueConstIterator(const LQueue< T > &queue, size_t pos=0)
Construct an LQueueIterator at position pos.
bool operator!=(const LQueueConstIterator< T > &lhs) const
Nonequality operator.
bool operator==(const LQueueConstIterator< T > &rhs) const
Equality operator.
Implements a forward iterator for LQueue type classes.
LQueue< T > & queue_
the queue we are dealing with
LQueueIterator(LQueue< T > &queue, size_t pos=0)
Construct an LQueueIterator at position pos.
bool operator==(const LQueueIterator< T > &rhs) const
Equality operator.
bool operator!=(const LQueueIterator< T > &lhs) const
Nonequality operator.
T & operator*(void)
Dereference operator returns a reference to the item contained at the current position.
LQueueIterator< T > & operator++(void)
Preincrement operator.
Defines a node in the LQueue that's implemented as a circular linked list.
LQueueNode(LQueueNode< T > *next)
Constructor.
LQueueNode< T > * next_
Pointer to the next node.
LQueueNode(const T &item, LQueueNode< T > *next=0)
Constructor.
static void free_list_allocate(size_t n)
Preallocate n LQueueNodes and store them on the free_list_.
T item_
Item in this node.
static LQueueNode< T > * free_list_
Head of the free list, which is a stack of LQueueNodes used to speed up allocation.
LQueueNode(void)
Default constructor that doesn't initialize item_.
static void free_list_release(void)
Returns all dynamic memory on the free list to the free store.
LQueueNode * next(void)
Return the next node to which this node points.
Exception thrown by methods in this class when an overflow condition occurs.
Exception thrown by methods in this class when an underflow condition occurs.
Defines a generic "first-in/first-out" (FIFO) Abstract Data Type (ADT) using a circular linked list.
LQueue< T > & operator=(const LQueue< T > &rhs)
Assignment operator.
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.
iterator begin(void)
Get an iterator that points to the beginning of the queue.
LQueueNode< T > * tail_
We only need to keep a single pointer for the circular linked list.
T dequeue(void)
Remove and return the front item on the queue.
LQueue(size_t size_hint=0)
Constructor.
LQueueConstIterator< T > const_iterator
void enqueue(const T &new_item)
Place a new_item at the tail of the queue.
bool operator==(const LQueue< T > &rhs) const
Compare this queue with rhs for equality.
size_t size(void) const
Returns the current number of elements in the queue.
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...
size_t count_
Number of items that are currently in the queue.
bool is_empty(void) const
Returns 1 if the queue is empty, otherwise returns 0.
void dequeue_i(void)
Remove the front item on the queue. Does not throw exceptions.
void copy_list(const LQueue< T > &rhs)
iterator end(void)
Get an iterator that points to the end of the queue.
LQueueIterator< T > iterator
Provides utility functions and classes for common tasks and needs.
Copyright(c) 2020 Galois.