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

Defines a generic "last-in/first-out" (LIFO) Abstract Data Type (ADT) using a stack that's implemented as a linked list. More...

#include <LStack.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 LStackConstIterator< T > const_iterator
 
typedef LStackIterator< T > iterator
 
typedef T value_type
 

Public Member Functions

 LStack (size_t size_hint=0)
 Constructor. More...
 
 LStack (const LStack< T > &rhs)
 Copy constructor. More...
 
 ~LStack (void)
 Perform actions needed when stack goes out of scope. More...
 
iterator begin (void)
 Get an iterator that points to the beginning of the stack. More...
 
const_iterator begin (void) const
 Get a const iterator that points to the beginning of the stack. More...
 
iterator end (void)
 Get an iterator that points to the end of the stack. More...
 
const_iterator end (void) const
 Get a const iterator that points to the end of the stack. More...
 
void erase (void)
 Delete all the nodes in the LStack. More...
 
bool is_empty (void) const
 Returns 1 if the stack is empty, otherwise returns 0. More...
 
bool is_full (void) const
 Returns 1 if the stack is full, otherwise returns 0. More...
 
bool operator!= (const LStack< T > &s) const
 
LStack< T > & operator= (const LStack< T > &rhs)
 Assignment operator. More...
 
bool operator== (const LStack< T > &rhs) const
 Compare this stack with rhs for equality. More...
 
pop (void)
 Remove and return the front item on the stack. More...
 
void push (const T &new_item)
 Place a new_item at the tail of the stack. More...
 
size_t size (void) const
 Returns the current number of elements in the stack. More...
 
top (void) const
 Returns the front stack item without removing it. More...
 

Protected Member Functions

void copy_list (const LStack< T > &rhs)
 Copy a linked list of nodes. More...
 
void delete_list (void)
 Delete a linked list of nodes. More...
 
void pop_i (void)
 Remove the front item on the stack. does not throw exceptions. More...
 

Private Attributes

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

Friends

class LStackConstIterator< T >
 
class LStackIterator< T >
 

Detailed Description

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

Defines a generic "last-in/first-out" (LIFO) Abstract Data Type (ADT) using a stack that's implemented as a linked list.

Definition at line 29 of file LStack.h.

Member Typedef Documentation

template<class T>
typedef LStackConstIterator<T> madara::utility::LStack< T >::const_iterator

Definition at line 99 of file LStack.h.

template<class T>
typedef LStackIterator<T> madara::utility::LStack< T >::iterator

Definition at line 98 of file LStack.h.

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

Definition at line 35 of file LStack.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 190 of file LStack.cpp.

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

Copy constructor.

Definition at line 202 of file LStack.cpp.

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

Perform actions needed when stack goes out of scope.

Definition at line 308 of file LStack.cpp.

Member Function Documentation

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

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

Definition at line 434 of file LStack.cpp.

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

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

Definition at line 450 of file LStack.cpp.

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

Copy a linked list of nodes.

This can throw a bad_alloc exception.

Definition at line 224 of file LStack.cpp.

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

Delete a linked list of nodes.

Definition at line 271 of file LStack.cpp.

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

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

Definition at line 442 of file LStack.cpp.

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

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

Definition at line 458 of file LStack.cpp.

template<class T >
void madara::utility::LStack< T >::erase ( void  )

Delete all the nodes in the LStack.

Definition at line 283 of file LStack.cpp.

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

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

Definition at line 418 of file LStack.cpp.

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

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

Definition at line 426 of file LStack.cpp.

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

Definition at line 330 of file LStack.cpp.

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

Assignment operator.

Definition at line 290 of file LStack.cpp.

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

Compare this stack with rhs for equality.

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

Definition at line 318 of file LStack.cpp.

template<class T >
T madara::utility::LStack< T >::pop ( void  )

Remove and return the front item on the stack.

Throws the Underflow exception if the stack is empty.

Definition at line 366 of file LStack.cpp.

template<class T >
void madara::utility::LStack< T >::pop_i ( void  )
protected

Remove the front item on the stack. does not throw exceptions.

Definition at line 386 of file LStack.cpp.

template<class T>
void madara::utility::LStack< T >::push ( const T &  new_item)

Place a new_item at the tail of the stack.

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

Definition at line 340 of file LStack.cpp.

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

Returns the current number of elements in the stack.

Definition at line 182 of file LStack.cpp.

template<class T >
T madara::utility::LStack< T >::top ( void  ) const

Returns the front stack item without removing it.

Throws the Underflow exception if the stack is empty.

Definition at line 405 of file LStack.cpp.

Friends And Related Function Documentation

template<class T>
friend class LStackConstIterator< T >
friend

Definition at line 32 of file LStack.h.

template<class T>
friend class LStackIterator< T >
friend

Definition at line 31 of file LStack.h.

Member Data Documentation

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

Number of items that are currently in the stack.

Definition at line 131 of file LStack.h.

template<class T>
LStackNode<T>* madara::utility::LStack< T >::head_
private

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

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

Definition at line 128 of file LStack.h.


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