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