libMesh::ElemHashUtils Struct Reference

A struct providing convenience functions for hashing elements. More...

#include <elem_hash.h>

Public Member Functions

std::size_t operator() (const Elem *elem) const
 
bool operator() (const Elem *lhs, const Elem *rhs) const
 

Detailed Description

A struct providing convenience functions for hashing elements.

The ElemHashUtils struct defines functions used for the "Hash" and "Pred" template arguments of the various "unordered" containers, e.g. template <class Key, // unordered_multiset::key_type/value_type class Hash = hash<Key>, // unordered_multiset::hasher class Pred = equal_to<Key>, // unordered_multiset::key_equal class Alloc = allocator<Key> // unordered_multiset::allocator_type > class unordered_multiset;

Author
John W. Peterson
Date
2015

Definition at line 45 of file elem_hash.h.

Member Function Documentation

std::size_t libMesh::ElemHashUtils::operator() ( const Elem elem) const
inline

The "Hash" template argument. A custom hash functor that can be used with the "unordered" container types.

Returns
A hash for the element computed by calling elem->key().

Definition at line 55 of file elem_hash.h.

References libMesh::Elem::key().

56  {
57  return cast_int<std::size_t>(elem->key());
58  }
bool libMesh::ElemHashUtils::operator() ( const Elem lhs,
const Elem rhs 
) const
inline

Satisfies the requirements of the "Pred" template parameter of the standard hash containers. We need to specify this in order to use the unordered_multiset, otherwise it just uses std::equal_to to compare two pointers...

Returns
true if the two Elem keys are equal, false otherwise.

Definition at line 69 of file elem_hash.h.

References libMesh::Elem::key().

70  {
71  return lhs->key() == rhs->key();
72  }

The documentation for this struct was generated from the following file: