10 #pragma warning(disable : 4355)
37 void*
operator new(
size_t bytes);
42 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)
188 : head_(0), count_(0)
199 : head_(0), count_(0)
228 ::std::unique_ptr<LStackNode<T> > new_node;
235 if (it == rhs.
begin())
239 temp.
head_ = new_node.release();
245 prev->
next_ = new_node.release();
255 ::std::swap(head_, temp.
head_);
258 ::std::swap(count_, temp.
count_);
314 return (size() == rhs.
size()) && ::std::equal(begin(), end(), rhs.
begin());
325 return !(*
this == rhs);
337 ::std::unique_ptr<LStackNode<T> > temp(
new LStackNode<T>(new_item, head_));
340 head_ = temp.release();
345 catch (const ::std::bad_alloc&)
369 T item = head_->item_;
512 return !(*
this == rhs);
522 for (pos = pos % (
stack_.count_ - 1); pos > 0; --pos)
578 return !(*
this == rhs);
588 for (pos = pos % (
stack_.count_ - 1); pos > 0; --pos)
Implements a forward iterator for LStack type classes.
LStackConstIterator(const LStack< T > &stack, size_t pos=0)
Construct an LStackIterator at position pos.
const LStackConstIterator< 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 LStack< T > & stack_
the stack we are dealing with
bool operator==(const LStackConstIterator< T > &rhs) const
Equality operator.
bool operator!=(const LStackConstIterator< T > &lhs) const
Nonequality operator.
Implements a forward iterator for LStack type classes.
bool operator!=(const LStackIterator< T > &lhs) const
Nonequality operator.
LStackIterator(LStack< T > &stack, size_t pos=0)
Construct an LStackIterator at position pos.
LStackIterator< T > & operator++(void)
Preincrement operator.
bool operator==(const LStackIterator< T > &rhs) const
Equality operator.
T & operator*(void)
Dereference operator returns a reference to the item contained at the current position.
LStack< T > & stack_
the stack we are dealing with
Defines a node in the LStack that's implemented as a linked list.
LStackNode(LStackNode< T > *next)
static LStackNode< T > * free_list_
static void free_list_allocate(size_t n)
static void free_list_release(void)
LStackNode(const T &item, LStackNode< T > *next=0)
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 "last-in/first-out" (LIFO) Abstract Data Type (ADT) using a stack that's implemente...
iterator begin(void)
Get an iterator that points to the beginning of the stack.
void pop_i(void)
Remove the front item on the stack. does not throw exceptions.
LStack(size_t size_hint=0)
Constructor.
void push(const T &new_item)
Place a new_item at the tail of the stack.
bool operator==(const LStack< T > &rhs) const
Compare this stack with rhs for equality.
void copy_list(const LStack< T > &rhs)
Copy a linked list of nodes.
void delete_list(void)
Delete a linked list of nodes.
bool is_full(void) const
Returns 1 if the stack is full, otherwise returns 0.
void erase(void)
Delete all the nodes in the LStack.
LStack< T > & operator=(const LStack< T > &rhs)
Assignment operator.
LStackIterator< T > iterator
LStackNode< T > * head_
We only need to keep a single pointer for the circular linked list.
size_t size(void) const
Returns the current number of elements in the stack.
iterator end(void)
Get an iterator that points to the end of the stack.
bool operator!=(const LStack< T > &s) const
T top(void) const
Returns the front stack item without removing it.
size_t count_
Number of items that are currently in the stack.
LStackConstIterator< T > const_iterator
T pop(void)
Remove and return the front item on the stack.
bool is_empty(void) const
Returns 1 if the stack is empty, otherwise returns 0.
Provides utility functions and classes for common tasks and needs.
Copyright(c) 2020 Galois.