Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ogdf::BoundedStack< E, INDEX > Class Template Reference

The parameterized class BoundedStack implements stacks with bounded size. More...

#include <ogdf/basic/BoundedStack.h>

Public Member Functions

 BoundedStack ()
 Constructs an empty bounded stack for no elements at all. More...
 
 BoundedStack (INDEX n)
 Constructs an empty bounded stack for at most n elements. More...
 
 BoundedStack (const BoundedStack< E > &S)
 Constructs a bounded stack that is a copy of S. More...
 
 BoundedStack (BoundedStack< E > &&S)
 Constructs a bounded stack containing the elements of S (move semantics). More...
 
 ~BoundedStack ()
 Destruction. More...
 
INDEX capacity () const
 Returns the capacity of the bounded stack. More...
 
void clear ()
 Makes the stack empty. More...
 
bool empty ()
 Returns true iff the stack is empty. More...
 
bool full ()
 Returns true iff the stack is full. More...
 
void init ()
 Reinitializes the stack for no elements at all (actually frees memory). More...
 
void init (INDEX n)
 Reinitializes the stack for n elements. More...
 
BoundedStack< E > & operator= (const BoundedStack< E > &S)
 Assignment operator. More...
 
BoundedStack< E > & operator= (BoundedStack< E > &&S)
 Assignment operator (move semantics). More...
 
E pop ()
 Removes the top-most element from the stack and returns it. More...
 
void print (ostream &os, char delim=' ') const
 Prints the stack to output stream os with the seperator delim. More...
 
void push (const E &x)
 Adds element x as top-most element to the stack. More...
 
INDEX size () const
 Returns current size of the stack. More...
 
const E & top () const
 Returns top element. More...
 
E & top ()
 Returns top element. More...
 
bool valid () const
 Returns true iff the stack was initialized. More...
 

Private Member Functions

void copy (const BoundedStack< E > &S)
 

Private Attributes

E * m_pStart
 Pointer to first element. More...
 
E * m_pStop
 Pointer to one past last element. More...
 
E * m_pTop
 Pointer to top element. More...
 

Detailed Description

template<class E, class INDEX = int>
class ogdf::BoundedStack< E, INDEX >

The parameterized class BoundedStack implements stacks with bounded size.

Template Parameters
Eis the element type.
INDEXis the index type. The default index type is int, other possible types are short and long long (on 64-bit systems).

Definition at line 46 of file BoundedStack.h.

Constructor & Destructor Documentation

◆ BoundedStack() [1/4]

template<class E, class INDEX = int>
ogdf::BoundedStack< E, INDEX >::BoundedStack ( )
inline

Constructs an empty bounded stack for no elements at all.

The default constructor does not allocate any space for elements; before using the stack, it is required to initialize the stack with init().

Definition at line 58 of file BoundedStack.h.

◆ BoundedStack() [2/4]

template<class E, class INDEX = int>
ogdf::BoundedStack< E, INDEX >::BoundedStack ( INDEX  n)
inlineexplicit

Constructs an empty bounded stack for at most n elements.

Definition at line 63 of file BoundedStack.h.

◆ BoundedStack() [3/4]

template<class E, class INDEX = int>
ogdf::BoundedStack< E, INDEX >::BoundedStack ( const BoundedStack< E > &  S)
inline

Constructs a bounded stack that is a copy of S.

Definition at line 72 of file BoundedStack.h.

◆ BoundedStack() [4/4]

template<class E, class INDEX = int>
ogdf::BoundedStack< E, INDEX >::BoundedStack ( BoundedStack< E > &&  S)
inline

Constructs a bounded stack containing the elements of S (move semantics).

The stack S is non valid afterwards, i.e., its capacity is zero. It has to be reinitialized if new elements shall be inserted.

Definition at line 81 of file BoundedStack.h.

◆ ~BoundedStack()

template<class E, class INDEX = int>
ogdf::BoundedStack< E, INDEX >::~BoundedStack ( )
inline

Destruction.

Definition at line 89 of file BoundedStack.h.

Member Function Documentation

◆ capacity()

template<class E, class INDEX = int>
INDEX ogdf::BoundedStack< E, INDEX >::capacity ( ) const
inline

Returns the capacity of the bounded stack.

Definition at line 118 of file BoundedStack.h.

◆ clear()

template<class E, class INDEX = int>
void ogdf::BoundedStack< E, INDEX >::clear ( )
inline

Makes the stack empty.

Definition at line 174 of file BoundedStack.h.

◆ copy()

template<class E, class INDEX = int>
void ogdf::BoundedStack< E, INDEX >::copy ( const BoundedStack< E > &  S)
inlineprivate

Definition at line 186 of file BoundedStack.h.

◆ empty()

template<class E, class INDEX = int>
bool ogdf::BoundedStack< E, INDEX >::empty ( )
inline

Returns true iff the stack is empty.

Definition at line 109 of file BoundedStack.h.

◆ full()

template<class E, class INDEX = int>
bool ogdf::BoundedStack< E, INDEX >::full ( )
inline

Returns true iff the stack is full.

Definition at line 112 of file BoundedStack.h.

◆ init() [1/2]

template<class E, class INDEX = int>
void ogdf::BoundedStack< E, INDEX >::init ( )
inline

Reinitializes the stack for no elements at all (actually frees memory).

Definition at line 121 of file BoundedStack.h.

◆ init() [2/2]

template<class E, class INDEX = int>
void ogdf::BoundedStack< E, INDEX >::init ( INDEX  n)
inline

Reinitializes the stack for n elements.

Definition at line 127 of file BoundedStack.h.

◆ operator=() [1/2]

template<class E, class INDEX = int>
BoundedStack<E>& ogdf::BoundedStack< E, INDEX >::operator= ( const BoundedStack< E > &  S)
inline

Assignment operator.

Definition at line 139 of file BoundedStack.h.

◆ operator=() [2/2]

template<class E, class INDEX = int>
BoundedStack<E>& ogdf::BoundedStack< E, INDEX >::operator= ( BoundedStack< E > &&  S)
inline

Assignment operator (move semantics).

The stack S is non valid afterwards, i.e., its capacity is zero. It has to be reinitialized if new elements shall be inserted.

Definition at line 150 of file BoundedStack.h.

◆ pop()

template<class E, class INDEX = int>
E ogdf::BoundedStack< E, INDEX >::pop ( )
inline

Removes the top-most element from the stack and returns it.

Definition at line 168 of file BoundedStack.h.

◆ print()

template<class E, class INDEX = int>
void ogdf::BoundedStack< E, INDEX >::print ( ostream &  os,
char  delim = ' ' 
) const
inline

Prints the stack to output stream os with the seperator delim.

Definition at line 177 of file BoundedStack.h.

◆ push()

template<class E, class INDEX = int>
void ogdf::BoundedStack< E, INDEX >::push ( const E &  x)
inline

Adds element x as top-most element to the stack.

Definition at line 162 of file BoundedStack.h.

◆ size()

template<class E, class INDEX = int>
INDEX ogdf::BoundedStack< E, INDEX >::size ( ) const
inline

Returns current size of the stack.

Definition at line 106 of file BoundedStack.h.

◆ top() [1/2]

template<class E, class INDEX = int>
const E& ogdf::BoundedStack< E, INDEX >::top ( ) const
inline

Returns top element.

Definition at line 94 of file BoundedStack.h.

◆ top() [2/2]

template<class E, class INDEX = int>
E& ogdf::BoundedStack< E, INDEX >::top ( )
inline

Returns top element.

Definition at line 100 of file BoundedStack.h.

◆ valid()

template<class E, class INDEX = int>
bool ogdf::BoundedStack< E, INDEX >::valid ( ) const
inline

Returns true iff the stack was initialized.

Definition at line 115 of file BoundedStack.h.

Member Data Documentation

◆ m_pStart

template<class E, class INDEX = int>
E* ogdf::BoundedStack< E, INDEX >::m_pStart
private

Pointer to first element.

Definition at line 49 of file BoundedStack.h.

◆ m_pStop

template<class E, class INDEX = int>
E* ogdf::BoundedStack< E, INDEX >::m_pStop
private

Pointer to one past last element.

Definition at line 50 of file BoundedStack.h.

◆ m_pTop

template<class E, class INDEX = int>
E* ogdf::BoundedStack< E, INDEX >::m_pTop
private

Pointer to top element.

Definition at line 48 of file BoundedStack.h.


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