dune-localfunctions  2.3beta2
localkey.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_LOCALKEY_HH
4 #define DUNE_LOCALKEY_HH
5 
6 #include <cstddef>
7 
8 #include <dune/common/array.hh>
9 
10 namespace Dune
11 {
20  class LocalKey
21  {
22  public:
23 
25  enum {
35  };
36 
39  {}
40 
46  LocalKey (unsigned int s, unsigned int c, unsigned int i)
47  {
48  values_[0] = s;
49  values_[1] = c;
50  values_[2] = i;
51  }
52 
54  inline unsigned int subEntity () const
55  {
56  return values_[0];
57  }
58 
60  inline unsigned int codim () const
61  {
62  return values_[1];
63  }
64 
66  inline unsigned int index () const
67  {
68  return values_[2];
69  }
70 
72  void index (unsigned int i)
73  {
74  values_[2] = i;
75  }
76 
78  bool operator< (const LocalKey& other) const
79  {
80  return values_ < other.values_;
81  }
82 
84  friend std::ostream& operator<< (std::ostream& s, const LocalKey& localKey)
85  {
86  return s << "[ subEntity: " << localKey.subEntity()
87  << ", codim: " << localKey.codim()
88  << ", index: " << localKey.index() << " ]";
89  }
90 
91  private:
92 
93  // We use an array to store the values in order to be able to use the array::operator< implementation
94  Dune::array<unsigned int,3> values_;
95 
96  };
97 
98 }
99 #endif