dune-fem  2.4.1-rc
idgridpart/iterator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_ITERATOR_HH
2 #define DUNE_FEM_GRIDPART_IDGRIDPART_ITERATOR_HH
3 
4 #include <type_traits>
5 #include <utility>
6 
7 #include <dune/grid/common/entitypointer.hh>
8 #include <dune/grid/common/gridenums.hh>
9 
10 namespace Dune
11 {
12 
13  namespace Fem
14  {
15 
16  // IdIterator
17  // ----------
18 
19  template< int codim, PartitionIteratorType pitype, class GridFamily >
20  class IdIterator
21  {
22  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
23 
24  typedef typename Traits::HostGridPartType HostGridPartType;
25 
26  public:
27  typedef typename Traits::ExtraData ExtraData;
28  typedef typename HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType;
29 
30  static const int codimension = HostIteratorType::codimension;
31 
32  typedef typename Traits::template Codim< codimension >::Entity Entity;
33 
34  IdIterator () = default;
35 
36  IdIterator ( ExtraData data, HostIteratorType hostIterator )
37  : data_( std::move( data ) ),
38  hostIterator_( std::move( hostIterator ) )
39  {}
40 
41  void increment ()
42  {
43  ++hostIterator_;
44  }
45 
46  Entity dereference () const
47  {
48  return typename Entity::Implementation( data_, *hostIterator_ );
49  }
50 
51  bool equals ( const IdIterator &rhs ) const
52  {
53  return hostIterator_ == rhs.hostIterator_;
54  }
55 
56  int level () const
57  {
58  return hostIterator_.level();
59  }
60 
61  operator Dune::DefaultEntityPointer< Entity > () const
62  {
63  return Dune::DefaultEntityPointer< Entity >( dereference() );
64  }
65 
66  bool equals ( const Dune::DefaultEntityPointer< Entity > &rhs ) const
67  {
68  return dereference() == rhs.dereference();
69  }
70 
71  private:
72  ExtraData data_;
73  HostIteratorType hostIterator_;
74  };
75 
76  } // namespace Fem
77 
78 } // namespace Dune
79 
80 #endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_ITERATOR_HH
IdIterator(ExtraData data, HostIteratorType hostIterator)
Definition: idgridpart/iterator.hh:36
HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType
Definition: idgridpart/iterator.hh:28
Entity dereference() const
Definition: idgridpart/iterator.hh:46
void increment()
Definition: idgridpart/iterator.hh:41
static const int codimension
Definition: idgridpart/iterator.hh:30
int level() const
Definition: idgridpart/iterator.hh:56
Definition: idgridpart/iterator.hh:20
Definition: coordinate.hh:4
STL namespace.
bool equals(const IdIterator &rhs) const
Definition: idgridpart/iterator.hh:51
Traits::template Codim< codimension >::Entity Entity
Definition: idgridpart/iterator.hh:32
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
Traits::ExtraData ExtraData
Definition: idgridpart/iterator.hh:27
bool equals(const Dune::DefaultEntityPointer< Entity > &rhs) const
Definition: idgridpart/iterator.hh:66