Skip to content
Snippets Groups Projects
Commit e9450f8a authored by Oliver Sander's avatar Oliver Sander
Browse files

class FiniteStack has been moved to the header finitestack.hh for consistency.

[[Imported from SVN: r5193]]
parent e283e98b
No related branches found
No related tags found
No related merge requests found
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_FINITE_STACK_HH
#define DUNE_FINITE_STACK_HH
#include <dune/common/exceptions.hh>
namespace Dune {
/*! \addtogroup Common
@{
*/
/*! \file
This file implements a stack classes FiniteStack. It is
mainly used by the grid iterators where exact knowledge of the stack
implementation is needed to guarantee efficient execution.
*/
/** \brief A stack with static memory allocation
*
This class implements a very efficient stack where the maximum
depth is known in advance. Note that no error checking is
performed!
\param n Maximum number of stack entries
*/
template<class T, int n>
class FiniteStack {
public:
//! Returns true if the stack is empty
bool empty () const
{
return f==0;
}
//! Returns true if the stack is full
bool full () const
{
return f>=n;
}
//! Puts a new object onto the stack
void push (const T& t)
{
s[f++] = t;
}
//! Removes and returns the uppermost object from the stack
T pop ()
{
return s[--f];
}
//! Returns the uppermost object on the stack
T top () const
{
return s[f-1];
}
//! Dynamic stacksize
int size () const
{
return f;
}
//! Makes empty stack
FiniteStack ()
{
f = 0;
}
private:
T s[n];
int f;
};
}
//! }@
#endif
......@@ -7,6 +7,11 @@
#include <dune/common/exceptions.hh>
#include <dune/common/deprecated.hh>
// Backward compatibility
#include <dune/common/finitestack.hh>
#warning This header is deprecated. Use std::stack instead of Dune::Stack. The class Dune::FiniteStack has been moved to finitestack.hh.
namespace Dune {
/*! \addtogroup Common
......@@ -15,9 +20,11 @@ namespace Dune {
/*! \file
This file implements two stack-classes Stack and FiniteStack. They are
This file implements a stack-classes Stack. It is
mainly used by the grid iterators where exact knowledge of the stack
implementation is needed to guarantee efficient execution
implementation is needed to guarantee efficient execution.
\deprecated std::stack is several times faster than this class.
*/
//! Exception thrown by the stack
......@@ -101,66 +108,6 @@ namespace Dune {
return t;
}
/** \brief A stack with static memory allocation
This class implements a very efficient stack where the maximum
depth is known in advance. Note that no error checking is
performed!
\param n Maximum number of stack entries
*/
template<class T, int n>
class FiniteStack {
public:
//! Returns true if the stack is empty
bool empty () const
{
return f==0;
}
//! Returns true if the stack is full
bool full () const
{
return f>=n;
}
//! Puts a new object onto the stack
void push (const T& t)
{
s[f++] = t;
}
//! Removes and returns the uppermost object from the stack
T pop ()
{
return s[--f];
}
//! Returns the uppermost object on the stack
T top () const
{
return s[f-1];
}
//! Dynamic stacksize
int size () const
{
return f;
}
//! Makes empty stack
FiniteStack ()
{
f = 0;
}
private:
T s[n];
int f;
};
}
//! }@
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment