1#ifndef DUNE_FEM_HPDG_SPACE_DISCONTINUOUSGALERKIN_LOCALDOFSTORAGE_HH
2#define DUNE_FEM_HPDG_SPACE_DISCONTINUOUSGALERKIN_LOCALDOFSTORAGE_HH
23 template<
class GlobalKey >
26 using ThisType = LocalDofStorage< GlobalKey >;
28 using container = std::vector< GlobalKey >;
32 using value_type = GlobalKey;
35 using iterator =
typename container::iterator;
37 using const_iterator =
typename container::const_iterator;
44 LocalDofStorage () : size_( 0 ), new_size_( 0 ) {}
53 LocalDofStorage (
const ThisType & ) =
default;
56 LocalDofStorage ( ThisType && ) =
default;
59 ThisType &operator= (
const ThisType & ) =
default;
62 ThisType &operator= ( ThisType && ) =
default;
69 iterator begin () {
return dofs_.begin(); }
72 const_iterator begin ()
const {
return dofs_.cbegin(); }
75 iterator end () {
return begin() +
size(); }
78 const_iterator end ()
const {
return begin() +
size(); }
85 std::size_t
size ()
const {
return size_; }
94 template<
class Function >
95 Function reserve ( std::size_t new_size, Function function )
101 const std::size_t old_size = dofs_.size();
102 if( old_size < new_size_ )
104 dofs_.resize( new_size );
105 for( std::size_t i = old_size; i < new_size; ++i )
106 dofs_[ i ] = function();
109 return std::move( function );
113 template<
class Function >
114 Function resize ( Function function )
116 assert( new_size_ <= dofs_.size() );
119 const std::size_t holes = dofs_.size() - size_;
120 std::for_each( dofs_.rbegin(), dofs_.rbegin() + holes, function );
122 dofs_.resize( size_ );
125 return std::move( function );
135 GlobalKey &operator[] ( std::size_t n ) {
return dofs_[ n ]; }
138 const GlobalKey &operator[] ( std::size_t n )
const {
return dofs_[ n ]; }
144 friend std::ostream &operator<< ( std::ostream &ostream,
const LocalDofStorage &storage )
146 const auto &dofs = storage.dofs_;
147 const std::size_t
size = dofs.size();
148 for( std::size_t i = 0; i <
size; ++i )
149 ostream << dofs[ i ] <<
" ";
150 ostream <<
"[" << storage.size_ <<
"; " << storage.new_size_ <<
"]";
157 std::size_t size_, new_size_;
158 std::vector< GlobalKey > dofs_;
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75