9 #pragma warning(disable:4355) 36 void *
operator new (
size_t bytes);
41 void operator delete (
void *ptr);
78 template <
class T>
void *
98 template <
class T>
void 123 template <
class T>
void 131 ::operator
delete (node);
138 template <
class T>
void 142 for (
size_t node_number = 0; node_number < n; ++node_number)
181 template <
class T>
size_t 210 ::std::unique_ptr <LStackNode<T> > tail (
new LStackNode<T> ());
223 template <
class T>
void 235 ::std::unique_ptr <LStackNode<T> > new_node;
243 if (it == rhs.
begin ())
247 temp.
head_ = new_node.release ();
253 prev->
next_ = new_node.release ();
270 template <
class T>
void 282 template <
class T>
void 317 template <
class T>
bool 329 template <
class T>
bool 333 return !(*
this == rhs);
339 template <
class T>
void 348 head_ = temp.release ();
353 catch (const ::std::bad_alloc&)
377 T item =
head_->item_;
385 template <
class T>
void 417 template <
class T>
bool 425 template <
class T>
bool 464 template <
typename T> T &
470 template <
typename T>
const T &
499 template <
typename T>
bool 509 template <
typename T>
bool 514 return !(*
this == rhs);
517 template <
typename T>
525 for (pos = pos % (
stack_.count_ -1);
534 template <
typename T>
542 template <
typename T>
const T &
570 template <
typename T>
579 template <
typename T>
bool 583 return !(*
this == rhs);
586 template <
typename T>
594 for (pos = pos % (
stack_.count_ -1);
603 template <
typename T>
bool operator==(const LStackIterator< T > &rhs) const
Equality operator.
size_t count_
Number of items that are currently in the stack.
T top(void) const
Returns the front stack item without removing it.
LStack< T > & operator=(const LStack< T > &rhs)
Assignment operator.
bool is_empty(void) const
Returns 1 if the stack is empty, otherwise returns 0.
T pop(void)
Remove and return the front item on the stack.
static void free_list_allocate(size_t n)
size_t size(void) const
Returns the current number of elements in the stack.
const LStackConstIterator< T > & operator++(void) const
Preincrement operator.
bool is_full(void) const
Returns 1 if the stack is full, otherwise returns 0.
static LStackNode< T > * free_list_
bool operator==(const LStack< T > &rhs) const
Compare this stack with rhs for equality.
~LStack(void)
Perform actions needed when stack goes out of scope.
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.
static void free_list_release(void)
const T & operator*(void) const
Dereference operator returns a const reference to the item contained at the current position...
LStackConstIterator(const LStack< T > &stack, size_t pos=0)
Construct an LStackIterator at position pos.
LStackIterator(LStack< T > &stack, size_t pos=0)
Construct an LStackIterator at position pos.
LStack< T > & stack_
the stack we are dealing with
bool operator==(const LStackConstIterator< T > &rhs) const
Equality operator.
void erase(void)
Delete all the nodes in the LStack.
T & operator*(void)
Dereference operator returns a reference to the item contained at the current position.
bool operator!=(const LStackConstIterator< T > &lhs) const
Nonequality operator.
bool operator!=(const LStack< T > &s) const
Implements a forward iterator for LStack type classes.
bool operator!=(const LStackIterator< T > &lhs) const
Nonequality operator.
void copy_list(const LStack< T > &rhs)
Copy a linked list of nodes.
iterator end(void)
Get an iterator that points to the end of the stack.
Provides utility functions and classes for common tasks and needs.
LStackIterator< T > iterator
Exception thrown by methods in this class when an underflow condition occurs.
LStack(size_t size_hint=0)
Constructor.
Defines a generic "last-in/first-out" (LIFO) Abstract Data Type (ADT) using a stack that's implemente...
Exception thrown by methods in this class when an overflow condition occurs.
Copyright (c) 2015 Carnegie Mellon University.
Implements a forward iterator for LStack type classes.
const LStack< T > & stack_
the stack we are dealing with
Defines a node in the LStack that's implemented as a linked list.
LStackConstIterator< T > const_iterator
void push(const T &new_item)
Place a new_item at the tail of the stack.
LStackNode< T > * head_
We only need to keep a single pointer for the circular linked list.
void delete_list(void)
Delete a linked list of nodes.
LStackIterator< T > & operator++(void)
Preincrement operator.