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