3#ifndef DUNE_PERSISTENTCONTAINERVECTOR_HH
4#define DUNE_PERSISTENTCONTAINERVECTOR_HH
16 template<
class G,
class IndexSet,
class Vector >
24 typedef typename Vector::value_type Value;
25 typedef typename Vector::size_type Size;
26 typedef typename Vector::const_iterator ConstIterator;
27 typedef typename Vector::iterator Iterator;
29 typedef typename Vector::allocator_type Allocator;
32 const Allocator &allocator = Allocator() )
34 indexSet_( &indexSet ),
35 data_( indexSet.
size( codim ), value, allocator )
38 template<
class Entity >
39 const Value &operator[] (
const Entity &entity )
const
42 const Size index = indexSet().
index( entity );
43 assert( index < data_.size() );
44 return data_[ index ];
47 template<
class Entity >
48 Value &operator[] (
const Entity &entity )
51 const Size index = indexSet().
index( entity );
52 assert( index < data_.size() );
53 return data_[ index ];
56 template<
class Entity >
57 const Value &operator() (
const Entity &entity,
int subEntity )
const
59 const Size index = indexSet().
subIndex( entity, subEntity, codimension() );
60 assert( index < data_.size() );
61 return data_[ index ];
64 template<
class Entity >
65 Value &operator() (
const Entity &entity,
int subEntity )
67 const Size index = indexSet().
subIndex( entity, subEntity, codimension() );
68 assert( index < data_.size() );
69 return data_[ index ];
72 Size size ()
const {
return data_.size(); }
74 void resize (
const Value &value = Value() )
76 const Size indexSetSize = indexSet().
size( codimension() );
77 data_.resize( indexSetSize, value );
80 void shrinkToFit () {}
82 void fill (
const Value &value ) { std::fill( begin(), end(), value ); }
84 void swap (
This &other )
86 std::swap( codim_, other.codim_ );
87 std::swap( indexSet_, other.indexSet_ );
88 std::swap( data_, other.data_ );
91 ConstIterator begin ()
const {
return data_.begin(); }
92 Iterator begin () {
return data_.begin(); }
94 ConstIterator end ()
const {
return data_.end(); }
95 Iterator end () {
return data_.end(); }
97 int codimension ()
const {
return codim_; }
102 typedef Grid GridType DUNE_DEPRECATED_MSG(
"Use Grid instead.");
122 const IndexSet &indexSet ()
const {
return *indexSet_; }
Wrapper class for entities.
Definition: entity.hh:57
@ codimension
Know your own codimension.
Definition: entity.hh:99
Index Set Interface base class.
Definition: indexidset.hh:78
IndexType index(const typename remove_const< GridImp >::type::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:107
IndexType size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:204
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:146
vector-based implementation of the PersistentContainer
Definition: persistentcontainervector.hh:18
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Dune namespace.
Definition: alignment.hh:14