Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ogdf::Stack< E > Class Template Reference

The parameterized class Stack<E> implements list-based stacks. More...

#include <ogdf/basic/Stack.h>

+ Inheritance diagram for ogdf::Stack< E >:

Public Types

using size_type = size_t
 The number of elements in the list. More...
 

Public Member Functions

 Stack ()
 Constructs an empty stack. More...
 
 Stack (std::initializer_list< E > initList)
 Constructs a stack and pushes the elements in initList on it (last element will be on top). More...
 
 Stack (const Stack< E > &S)
 Constructs a stack that is a copy of S. More...
 
 Stack (Stack< E > &&S)
 Constructs a stack containing the elements of S (move semantics). More...
 
 ~Stack ()
 Destruction. More...
 
void clear ()
 Makes the stack empty. More...
 
template<class ... Args>
void emplace (Args &&... args)
 Adds a new element at as top-most element to the stack. More...
 
bool empty () const
 Returns true iff the stack is empty. More...
 
Stack< E > & operator= (const Stack< E > &S)
 Assignment operator. More...
 
Stack< E > & operator= (Stack< 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
 
void push (const E &x)
 Adds element x as top-most element to the stack. More...
 
size_t size () const
 Returns the number of elements contained in the stack. More...
 
const E & top () const
 Returns a reference to the top element. More...
 
E & top ()
 Returns a reference to the top element. More...
 

Private Attributes

size_t m_count
 

Additional Inherited Members

- Private Member Functions inherited from ogdf::StackPure< E >
 StackPure ()
 Constructs an empty stack. More...
 
 StackPure (std::initializer_list< E > initList)
 Constructs a stack and pushes the elements in initList on it (last element will be on top). More...
 
 StackPure (const StackPure< E > &S)
 Constructs a stack that is a copy of S. More...
 
 StackPure (StackPure< E > &&S)
 Constructs a stack containing the elements of S (move semantics). More...
 
 ~StackPure ()
 Destruction. More...
 
void clear ()
 Makes the stack empty. More...
 
template<class ... Args>
void emplace (Args &&... args)
 Adds a new element at as top-most element to the stack. More...
 
bool empty () const
 Returns true iff the stack is empty. More...
 
StackPure< E > & operator= (const StackPure< E > &S)
 Assignment operator. More...
 
StackPure< E > & operator= (StackPure< 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
 
void push (const E &x)
 Adds element x as top-most element to the stack. More...
 
const E & top () const
 Returns a reference to the top element. More...
 
E & top ()
 Returns a reference to the top element. More...
 

Detailed Description

template<class E>
class ogdf::Stack< E >

The parameterized class Stack<E> implements list-based stacks.

In contrast to StackPure<E>, instances of Stack<E> store the number of elements contained in the stack.

Template Parameters
Eis the element type.

Definition at line 192 of file Stack.h.

Member Typedef Documentation

◆ size_type

template<class E>
using ogdf::Stack< E >::size_type = size_t

The number of elements in the list.

Definition at line 197 of file Stack.h.

Constructor & Destructor Documentation

◆ Stack() [1/4]

template<class E>
ogdf::Stack< E >::Stack ( )
inline

Constructs an empty stack.

Definition at line 200 of file Stack.h.

◆ Stack() [2/4]

template<class E>
ogdf::Stack< E >::Stack ( std::initializer_list< E >  initList)
inline

Constructs a stack and pushes the elements in initList on it (last element will be on top).

Definition at line 203 of file Stack.h.

◆ Stack() [3/4]

template<class E>
ogdf::Stack< E >::Stack ( const Stack< E > &  S)
inline

Constructs a stack that is a copy of S.

Definition at line 208 of file Stack.h.

◆ Stack() [4/4]

template<class E>
ogdf::Stack< E >::Stack ( Stack< E > &&  S)
inline

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

Stack S is empty afterwards.

Definition at line 214 of file Stack.h.

◆ ~Stack()

template<class E>
ogdf::Stack< E >::~Stack ( )
inline

Destruction.

Definition at line 219 of file Stack.h.

Member Function Documentation

◆ clear()

template<class E>
void ogdf::Stack< E >::clear ( )
inline

Makes the stack empty.

Definition at line 278 of file Stack.h.

◆ emplace()

template<class E>
template<class ... Args>
void ogdf::Stack< E >::emplace ( Args &&...  args)
inline

Adds a new element at as top-most element to the stack.

The element is constructed in-place with exactly the same arguments args as supplied to the function.

Definition at line 266 of file Stack.h.

◆ empty()

template<class E>
bool ogdf::Stack< E >::empty ( ) const
inline

Returns true iff the stack is empty.

Definition at line 222 of file Stack.h.

◆ operator=() [1/2]

template<class E>
Stack<E>& ogdf::Stack< E >::operator= ( const Stack< E > &  S)
inline

Assignment operator.

Definition at line 238 of file Stack.h.

◆ operator=() [2/2]

template<class E>
Stack<E>& ogdf::Stack< E >::operator= ( Stack< E > &&  S)
inline

Assignment operator (move semantics).

Stack S is empty afterwards.

Definition at line 248 of file Stack.h.

◆ pop()

template<class E>
E ogdf::Stack< E >::pop ( )
inline

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

Definition at line 272 of file Stack.h.

◆ print()

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

Definition at line 283 of file Stack.h.

◆ push()

template<class E>
void ogdf::Stack< E >::push ( const E &  x)
inline

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

Definition at line 256 of file Stack.h.

◆ size()

template<class E>
size_t ogdf::Stack< E >::size ( ) const
inline

Returns the number of elements contained in the stack.

Definition at line 225 of file Stack.h.

◆ top() [1/2]

template<class E>
const E& ogdf::Stack< E >::top ( ) const
inline

Returns a reference to the top element.

Definition at line 228 of file Stack.h.

◆ top() [2/2]

template<class E>
E& ogdf::Stack< E >::top ( )
inline

Returns a reference to the top element.

Definition at line 233 of file Stack.h.

Member Data Documentation

◆ m_count

template<class E>
size_t ogdf::Stack< E >::m_count
private

Definition at line 194 of file Stack.h.


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