Dune Core Modules (unstable)

persistentcontainer.hh
1// SPDX-FileCopyrightText: Copyright © 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
10#include <dune/grid/utility/persistentcontainermap.hh>
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
map-based implementation of the PersistentContainer
Definition: persistentcontainermap.hh:26
A class for storing data during an adaptation cycle.
Definition: persistentcontainer.hh:22
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)