/usr/include/dune/grid/utility/persistentcontainervector.hh is in libdune-grid-dev 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PERSISTENTCONTAINERVECTOR_HH
#define DUNE_PERSISTENTCONTAINERVECTOR_HH
#include <algorithm>
#include <cassert>
namespace Dune
{
// PersistentContainerVector
// -------------------------
/** \brief vector-based implementation of the PersistentContainer */
template< class G, class IndexSet, class Vector >
class PersistentContainerVector
{
typedef PersistentContainerVector< G, IndexSet, Vector > This;
public:
typedef G Grid;
typedef typename Vector::value_type Value;
typedef typename Vector::size_type Size;
typedef typename Vector::const_iterator ConstIterator;
typedef typename Vector::iterator Iterator;
typedef typename Vector::allocator_type Allocator;
PersistentContainerVector ( const IndexSet &indexSet, int codim, const Value &value,
const Allocator &allocator = Allocator() )
: codim_( codim ),
indexSet_( &indexSet ),
data_( indexSet.size( codim ), value, allocator )
{}
template< class Entity >
const Value &operator[] ( const Entity &entity ) const
{
assert( Entity::codimension == codimension() );
const Size index = indexSet().index( entity );
assert( index < data_.size() );
return data_[ index ];
}
template< class Entity >
Value &operator[] ( const Entity &entity )
{
assert( Entity::codimension == codimension() );
const Size index = indexSet().index( entity );
assert( index < data_.size() );
return data_[ index ];
}
template< class Entity >
const Value &operator() ( const Entity &entity, int subEntity ) const
{
const Size index = indexSet().subIndex( entity, subEntity, codimension() );
assert( index < data_.size() );
return data_[ index ];
}
template< class Entity >
Value &operator() ( const Entity &entity, int subEntity )
{
const Size index = indexSet().subIndex( entity, subEntity, codimension() );
assert( index < data_.size() );
return data_[ index ];
}
Size size () const { return data_.size(); }
void resize ( const Value &value = Value() )
{
const Size indexSetSize = indexSet().size( codimension() );
data_.resize( indexSetSize, value );
}
void shrinkToFit () {}
void fill ( const Value &value ) { std::fill( begin(), end(), value ); }
void swap ( This &other )
{
std::swap( codim_, other.codim_ );
std::swap( indexSet_, other.indexSet_ );
std::swap( data_, other.data_ );
}
ConstIterator begin () const { return data_.begin(); }
Iterator begin () { return data_.begin(); }
ConstIterator end () const { return data_.end(); }
Iterator end () { return data_.end(); }
int codimension () const { return codim_; }
// deprecated stuff, will be removed after Dune 2.3
typedef Grid GridType DUNE_DEPRECATED_MSG("Use Grid instead.");
typedef Value Data DUNE_DEPRECATED_MSG("Use Value instead.");
void reserve () DUNE_DEPRECATED_MSG("Use resize() instead.")
{ return resize(); }
void clear () DUNE_DEPRECATED_MSG("Use resize() instead.")
{
resize( Value() );
shrinkToFit();
fill( Value() );
}
void update () DUNE_DEPRECATED_MSG("Use resize() instead.")
{
resize( Value() );
shrinkToFit();
}
protected:
const IndexSet &indexSet () const { return *indexSet_; }
int codim_;
const IndexSet *indexSet_;
Vector data_;
};
} // namespace Dune
#endif // #ifndef DUNE_PERSISTENTCONTAINERVECTOR_HH
|