elem_hash.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_ELEM_HASH_H
19 #define LIBMESH_ELEM_HASH_H
20 
21 #include "elem.h"
22 
23 // C++ includes
24 #include <unordered_set>
25 
26 // This header defines some typedefs that are useful for working with
27 // "unordered" containers of Elem * that use Elem::key() as a hash
28 // function.
29 namespace libMesh
30 {
31 
47 {
48 public:
55  inline
56  std::size_t operator()(const Elem * elem) const
57  {
58  return cast_int<std::size_t>(elem->key());
59  }
60 
69  inline
70  bool operator()(const Elem * lhs, const Elem * rhs) const
71  {
72  return lhs->key() == rhs->key();
73  }
74 };
75 
76 // A convenient type for working with unordered_multiset<Elem *>
77 typedef std::unordered_multiset<Elem *, ElemHashUtils, ElemHashUtils> unordered_multiset_elem;
78 
79 }
80 
81 #endif
A struct providing convenience functions for hashing elements.
Definition: elem_hash.h:46
The base class for all geometric element types.
Definition: elem.h:100
bool operator()(const Elem *lhs, const Elem *rhs) const
Definition: elem_hash.h:70
virtual dof_id_type key(const unsigned int s) const =0
std::size_t operator()(const Elem *elem) const
Definition: elem_hash.h:56
std::unordered_multiset< Elem *, ElemHashUtils, ElemHashUtils > unordered_multiset_elem
Definition: elem_hash.h:77