MFEM  v4.6.0
Finite element discretization library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mfem::HashFunction Class Reference

Hash function for data sequences. More...

#include <hash.hpp>

Public Member Functions

 HashFunction ()
 Default constructor: initialize the hash function. More...
 
 ~HashFunction ()
 Destructor. More...
 
HashFunctionAppendBytes (const void *seq, size_t num_bytes)
 Add a sequence of bytes for hashing. More...
 
template<typename int_type >
HashFunctionAppendInts (const int_type *ints, size_t num_ints)
 Add a sequence of integers for hashing, given as a c-array. More...
 
template<typename int_type , size_t num_ints>
HashFunctionAppendInts (const int_type(&ints)[num_ints])
 Add a sequence of integers for hashing, given as a fixed-size c-array. More...
 
template<typename int_type_container >
HashFunctionAppendInts (const int_type_container &ints)
 Add a sequence of integers for hashing, given as a container. More...
 
HashFunctionAppendDoubles (const double *doubles, size_t num_doubles)
 Add a sequence of doubles for hashing, given as a c-array. More...
 
template<size_t num_doubles>
HashFunctionAppendDoubles (const double(&doubles)[num_doubles])
 Add a sequence of doubles for hashing, given as a fixed-size c-array. More...
 
template<typename double_container >
HashFunctionAppendDoubles (const double_container &doubles)
 Add a sequence of doubles for hashing, given as a container. More...
 
std::string GetHash () const
 Return the hash string for the current sequence and reset (clear) the sequence. More...
 

Protected Member Functions

void HashBuffer (const void *buffer, size_t num_bytes)
 Add a sequence of bytes for hashing. More...
 
template<typename int_type_const_iter >
HashFunctionEncodeAndHashInts (int_type_const_iter begin, int_type_const_iter end)
 Integer encoding method; result is independent of endianness and type. More...
 
template<typename double_const_iter >
HashFunctionEncodeAndHashDoubles (double_const_iter begin, double_const_iter end)
 Double encoding method: encode in little-endian byte-order. More...
 

Protected Attributes

void * hash_data
 

Detailed Description

Hash function for data sequences.

Depends on GnuTLS for SHA-256 hashing.

Definition at line 456 of file hash.hpp.

Constructor & Destructor Documentation

◆ HashFunction()

mfem::HashFunction::HashFunction ( )

Default constructor: initialize the hash function.

Definition at line 29 of file hash.cpp.

◆ ~HashFunction()

mfem::HashFunction::~HashFunction ( )

Destructor.

Definition at line 38 of file hash.cpp.

Member Function Documentation

◆ AppendBytes()

HashFunction& mfem::HashFunction::AppendBytes ( const void *  seq,
size_t  num_bytes 
)
inline

Add a sequence of bytes for hashing.

Definition at line 482 of file hash.hpp.

◆ AppendDoubles() [1/3]

HashFunction& mfem::HashFunction::AppendDoubles ( const double *  doubles,
size_t  num_doubles 
)
inline

Add a sequence of doubles for hashing, given as a c-array.

Before hashing the sequence is encoded so that the result is independent of endianness.

Definition at line 509 of file hash.hpp.

◆ AppendDoubles() [2/3]

template<size_t num_doubles>
HashFunction& mfem::HashFunction::AppendDoubles ( const double(&)  doubles[num_doubles])
inline

Add a sequence of doubles for hashing, given as a fixed-size c-array.

Before hashing the sequence is encoded so that the result is independent of endianness.

Definition at line 516 of file hash.hpp.

◆ AppendDoubles() [3/3]

template<typename double_container >
HashFunction& mfem::HashFunction::AppendDoubles ( const double_container &  doubles)
inline

Add a sequence of doubles for hashing, given as a container.

Before hashing the sequence is encoded so that the result is independent of endianness.

Definition at line 523 of file hash.hpp.

◆ AppendInts() [1/3]

template<typename int_type >
HashFunction& mfem::HashFunction::AppendInts ( const int_type *  ints,
size_t  num_ints 
)
inline

Add a sequence of integers for hashing, given as a c-array.

Before hashing the sequence is encoded so that the result is independent of endianness and type: int, long, unsigned, etc.

Definition at line 489 of file hash.hpp.

◆ AppendInts() [2/3]

template<typename int_type , size_t num_ints>
HashFunction& mfem::HashFunction::AppendInts ( const int_type(&)  ints[num_ints])
inline

Add a sequence of integers for hashing, given as a fixed-size c-array.

Before hashing the sequence is encoded so that the result is independent of endianness and type: int, long, unsigned, etc.

Definition at line 496 of file hash.hpp.

◆ AppendInts() [3/3]

template<typename int_type_container >
HashFunction& mfem::HashFunction::AppendInts ( const int_type_container &  ints)
inline

Add a sequence of integers for hashing, given as a container.

Before hashing the sequence is encoded so that the result is independent of endianness and type: int, long, unsigned, etc.

Definition at line 503 of file hash.hpp.

◆ EncodeAndHashDoubles()

template<typename double_const_iter >
HashFunction & mfem::HashFunction::EncodeAndHashDoubles ( double_const_iter  begin,
double_const_iter  end 
)
protected

Double encoding method: encode in little-endian byte-order.

Definition at line 985 of file hash.hpp.

◆ EncodeAndHashInts()

template<typename int_type_const_iter >
HashFunction & mfem::HashFunction::EncodeAndHashInts ( int_type_const_iter  begin,
int_type_const_iter  end 
)
protected

Integer encoding method; result is independent of endianness and type.

Definition at line 935 of file hash.hpp.

◆ GetHash()

std::string mfem::HashFunction::GetHash ( ) const

Return the hash string for the current sequence and reset (clear) the sequence.

Definition at line 60 of file hash.cpp.

◆ HashBuffer()

void mfem::HashFunction::HashBuffer ( const void *  buffer,
size_t  num_bytes 
)
protected

Add a sequence of bytes for hashing.

Definition at line 45 of file hash.cpp.

Member Data Documentation

◆ hash_data

void* mfem::HashFunction::hash_data
protected

Definition at line 459 of file hash.hpp.


The documentation for this class was generated from the following files: