dune-grid  2.6-git
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  {
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 >
59  class PersistentContainer
60  : public PersistentContainerMap< G, typename G::LocalIdSet, std::unordered_map< typename G::LocalIdSet::IdType, T > >
61  {
62  typedef PersistentContainerMap< G, typename G::LocalIdSet, std::unordered_map< typename G::LocalIdSet::IdType, T > > Base;
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
Dune::PersistentContainer< const Grid, T >::Value
Base::Value Value
Definition: utility/persistentcontainer.hh:39
Dune::PersistentContainer::PersistentContainer
PersistentContainer(const Grid &grid, int codim, const Value &value=Value())
Definition: utility/persistentcontainer.hh:27
std::swap
void swap(Dune::PersistentContainer< G, T > &a, Dune::PersistentContainer< G, T > &b)
Definition: utility/persistentcontainer.hh:81
Dune::PersistentContainerMap< G, G::LocalIdSet, std::map< G::LocalIdSet::IdType, T > >::swap
void swap(This &other)
Definition: persistentcontainermap.hh:94
Dune::PersistentContainer::Value
Base::Value Value
Definition: utility/persistentcontainer.hh:25
Dune::PersistentContainerMap
map-based implementation of the PersistentContainer
Definition: persistentcontainermap.hh:22
Dune::PersistentContainerMap< G, G::LocalIdSet, std::map< G::LocalIdSet::IdType, T > >::grid
const Grid & grid() const
Definition: persistentcontainermap.hh:111
Dune::PersistentContainerMap::Grid
G Grid
Definition: persistentcontainermap.hh:28
persistentcontainermap.hh
Dune::PersistentContainer< const Grid, T >::PersistentContainer
PersistentContainer(const typename Base::Grid &grid, int codim, const Value &value=Value())
Definition: utility/persistentcontainer.hh:41
Dune::PersistentContainerMap::Value
Map::mapped_type Value
Definition: persistentcontainermap.hh:33
Dune::PersistentContainer
A class for storing data during an adaptation cycle.
Definition: utility/persistentcontainer.hh:18
Dune::PersistentContainer::Grid
Base::Grid Grid
Definition: utility/persistentcontainer.hh:24
Dune
Include standard header files.
Definition: agrid.hh:58