5#ifndef DUNE_PERSISTENTCONTAINERVECTOR_HH
6#define DUNE_PERSISTENTCONTAINERVECTOR_HH
49 template<
class G,
class IndexSet,
class Vector >
57 typedef typename Vector::value_type Value;
58 typedef typename Vector::size_type Size;
59 typedef typename Vector::const_iterator ConstIterator;
60 typedef typename Vector::iterator Iterator;
62 typedef typename Vector::allocator_type Allocator;
65 const Allocator &allocator = Allocator() )
67 indexSet_( &indexSet ),
68 data_( indexSet.
size( codim ), value, allocator )
71 template<
class Entity >
72 const Value &operator[] (
const Entity &entity )
const
75 const Size index = indexSet().
index( entity );
76 assert( index < data_.size() );
77 return data_[ index ];
80 template<
class Entity >
81 Value &operator[] (
const Entity &entity )
84 const Size index = indexSet().
index( entity );
85 assert( index < data_.size() );
86 return data_[ index ];
89 template<
class Entity >
90 const Value &operator() (
const Entity &entity,
int subEntity )
const
92 const Size index = indexSet().
subIndex( entity, subEntity, codimension() );
93 assert( index < data_.size() );
94 return data_[ index ];
97 template<
class Entity >
98 Value &operator() (
const Entity &entity,
int subEntity )
100 const Size index = indexSet().
subIndex( entity, subEntity, codimension() );
101 assert( index < data_.size() );
102 return data_[ index ];
105 Size size ()
const {
return data_.size(); }
107 void resize (
const Value &value = Value() )
109 const Size indexSetSize = indexSet().
size( codimension() );
110 data_.resize( indexSetSize, value );
113 void shrinkToFit () {}
115 void fill (
const Value &value ) { std::fill( begin(), end(), value ); }
117 void swap (
This &other )
119 std::swap( codim_, other.codim_ );
120 std::swap( indexSet_, other.indexSet_ );
121 std::swap( data_, other.data_ );
124 ConstIterator begin ()
const {
return data_.begin(); }
125 Iterator begin () {
return data_.begin(); }
127 ConstIterator end ()
const {
return data_.end(); }
128 Iterator end () {
return data_.end(); }
130 int codimension ()
const {
return codim_; }
133 const IndexSet &indexSet ()
const {
return *indexSet_; }
Wrapper class for entities.
Definition: entity.hh:66
static constexpr int codimension
Know your own codimension.
Definition: entity.hh:106
Index Set Interface base class.
Definition: indexidset.hh:78
auto size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:223
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: indexidset.hh:153
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: indexidset.hh:113
vector-based implementation of the PersistentContainer
Definition: persistentcontainervector.hh:51
Dune namespace.
Definition: alignedallocator.hh:13