Skip to content
Snippets Groups Projects
Commit 50f10eb1 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

Remove deprecated finitestack.

[[Imported from SVN: r6795]]
parent 8c3b4c9f
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,6 @@ commoninclude_HEADERS = \
enumset.hh \
exceptions.hh \
fassign.hh \
finitestack.hh \
float_cmp.cc \
float_cmp.hh \
fmatrix.hh \
......
// -*- 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
/** \file
* \brief Stack class of fixed maximum size (deprecated)
*/
#warning This file is deprecated and will be removed after the release of dune-common-2.2.\
Please use std::stack<Dune::ReservedVector> instead of FiniteStack.
#include <stack>
#include <dune/common/exceptions.hh>
#include <dune/common/reservedvector.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 std::stack<T, Dune::ReservedVector<T,n> >
{
public:
//! Returns true if the stack is full
bool full () const
{
return this->size()>=n;
}
/** Removes and returns the uppermost object from the stack
\warning This differs from the semantics of std::stack, where pop() returns void
*/
T pop ()
{
#ifndef NDEBUG
if (this->empty())
DUNE_THROW(Dune::RangeError, "trying to call pop() on an empty FiniteStack");
#endif
T tmp = this->top();
this->std::stack<T,Dune::ReservedVector<T,n> >::pop();
return tmp;
}
};
}
//! }@
#endif
......@@ -7,7 +7,6 @@ dynvectortest
fvectortest
mpicollectivecommunication
lrutest
test-stack
arraylisttest
shared_ptrtest
testfloatcmp
......@@ -44,7 +43,6 @@ testfassign1
testfassign2
testfassign3
testfassign4
smallobject
conversiontest
nullptr-test
blockbitfieldtest
......
......@@ -31,7 +31,6 @@ TESTPROGS = \
singletontest \
static_assert_test \
streamtest \
test-stack \
testfassign1 \
testfassign2 \
testfassign3 \
......@@ -114,8 +113,6 @@ lrutest_SOURCES = lrutest.cc
sllisttest_SOURCES = sllisttest.cc
test_stack_SOURCES = test-stack.cc
arraylisttest_SOURCES = arraylisttest.cc
arraytest_SOURCES = arraytest.cc
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// $Id$
#ifdef NDEBUG
#warning "Disabling NDEBUG for this test, otherwise it will fail!"
#undef NDEBUG
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <cassert>
#include <iostream>
#include <dune/common/finitestack.hh>
// stack depth to test
static const int MAX = 100;
template <class SType>
void exercise_stack (SType &S) {
assert(S.empty());
// fill stack to maximum
for (int i = 0; i < MAX; ++i) {
assert(! S.full());
S.push(i);
assert(! S.empty());
};
for (int i = MAX - 1; i >= 0; --i) {
int x = S.top();
int y = S.pop();
assert(x == i);
assert(y == i);
};
assert(S.empty());
}
int main () {
// initialize stack, push stuff and check if it comes out again
Dune::FiniteStack<int, MAX> fixedstack;
exercise_stack(fixedstack);
// check error handling of Stack
try {
Dune::FiniteStack<int, MAX> stack1;
assert(stack1.empty());
stack1.pop();
// exception has to happen
// make sure you compile this test without NDEBUG
std::cerr << "Expected exception Dune::RangeError, but nothing caught\n";
return 1;
} catch (Dune::RangeError &e) {
// exception was correctly reported
std::cerr << "Caught expected Dune::RangeError: " << e.what() << std::endl;
return 0;
} catch (Dune::Exception &e) {
// exception was correctly reported
std::cerr << "Dune::Exception: " << e.what() << std::endl;
return 1;
} catch (std::exception &e) {
// exception was correctly reported
std::cerr << "std::exception: " << e.what() << std::endl;
return 1;
} catch (...) {
// wrong type of exception
std::cerr << "unknown exception\n";
return 1;
}
}
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