libMesh
Public Member Functions | List of all members
libMesh::ElemHashUtils Struct Reference

The ElemHashUtils struct defines functions used for the "Hash" and "Pred" template arguments of the various "unordered" containers, e.g. More...

#include <elem_hash.h>

Public Member Functions

std::size_t operator() (const Elem *elem) const
 The "Hash" template argument. More...
 
bool operator() (const Elem *lhs, const Elem *rhs) const
 Satisfies the requirements of the "Pred" template parameter of the standard hash containers. More...
 

Detailed Description

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 A struct providing convenience functions for hashing elements.

Definition at line 46 of file elem_hash.h.

Member Function Documentation

◆ operator()() [1/2]

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 56 of file elem_hash.h.

References libMesh::Elem::key().

57  {
58  return cast_int<std::size_t>(elem->key());
59  }

◆ operator()() [2/2]

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 70 of file elem_hash.h.

References libMesh::Elem::key().

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

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