dune-grid  2.4.1-rc2
utility/persistentcontainer.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_PERSISTENTCONTAINER_HH
4 #define DUNE_PERSISTENTCONTAINER_HH
5 
6 #include <map>
7 
9 
10 namespace Dune
11 {
12 
17  template< class G, class T >
19  : public PersistentContainerMap< G, typename G::LocalIdSet, std::map< typename G::LocalIdSet::IdType, T > >
20  {
22 
23  public:
24  typedef typename Base::Grid Grid;
25  typedef typename Base::Value Value;
26 
27  PersistentContainer ( const Grid &grid, int codim, const Value &value = Value() )
28  : Base( grid, codim, grid.localIdSet(), value )
29  {}
30  };
31 
33  template< class Grid, class T >
34  class PersistentContainer< const Grid, T >
35  : public PersistentContainer< Grid, T >
36  {
37  typedef PersistentContainer< Grid, T > Base;
38  public:
39  typedef typename Base::Value Value;
40 
41  PersistentContainer ( const typename Base::Grid &grid, int codim, const Value &value = Value() )
42  : Base(grid, codim, value)
43  {}
44  };
45 
46 } // namespace Dune
47 
48 
49 #if 0
50 
51 // the following implementation can be used for a grid providing a hash for the id type
52 
53 #include <unordered_map>
54 
55 namespace Dune
56 {
57 
58  template< G, class T >
60  : public PersistentContainerMap< G, typename G::LocalIdSet, std::unordered_map< typename G::LocalIdSet::IdType, T > >
61  {
63 
64  public:
65  typedef typename Base::Grid Grid;
66  typedef typename Base::Value Value;
67 
68  PersistentContainer ( const Grid &grid, int codim, const Value &value )
69  : Base( grid, codim, grid.localIdSet(), value )
70  {}
71  };
72 
73 } // namespace Dune
74 
75 #endif // #if 0
76 
77 namespace std
78 {
79 
80  template< class G, class T >
82  {
83  a.swap( b );
84  }
85 
86 } // namespace std
87 
88 #endif // #ifndef DUNE_PERSISTENTCONTAINER_HH
Map::mapped_type Value
Definition: persistentcontainermap.hh:35
A class for storing data during an adaptation cycle.
Definition: utility/persistentcontainer.hh:18
void swap(This &other)
Definition: persistentcontainermap.hh:95
G Grid
Definition: persistentcontainermap.hh:30
Base::Grid Grid
Definition: utility/persistentcontainer.hh:24
PersistentContainer(const Grid &grid, int codim, const Value &value=Value())
Definition: utility/persistentcontainer.hh:27
PersistentContainer(const typename Base::Grid &grid, int codim, const Value &value=Value())
Definition: utility/persistentcontainer.hh:41
const Grid & grid() const
Definition: persistentcontainermap.hh:112
Base::Value Value
Definition: utility/persistentcontainer.hh:39
Include standard header files.
Definition: agrid.hh:59
STL namespace.
Base::Value Value
Definition: utility/persistentcontainer.hh:25
map-based implementation of the PersistentContainer
Definition: persistentcontainermap.hh:21