Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::hash_t Struct Reference

#include <hash_t.h>

Public Member Functions

 hash_t (std::uint64_t a=0, std::uint64_t b=0)
void clear () noexcept
 Resets the content of the object.
bool operator== (const hash_t &) const noexcept=default
 Standard equality operator for hash signature.
bool operator< (const hash_t &rhs) const noexcept
void combine (hash_t h) noexcept
bool empty () const noexcept
 We assume that a string of 128 zero bits means empty.
bool load (std::istream &)
bool save (std::ostream &) const

Public Attributes

std::uint64_t data [2]

Detailed Description

A 128bit unsigned integer used as individual's signature / hash table look-up key.

Member Function Documentation

◆ combine()

void ultra::hash_t::combine ( hash_t h)
inlinenoexcept

Combines another hash into this instance.

Parameters
[in]hhash to be combined

Uses prime-number multiplication (data = data * 37 + h), which preserves order sensitivity (unlike commutative XOR).

Note
A default-constructed hash_t ({0, 0}, which evaluates to empty()) acts as a left-identity: starting from an empty accumulator and combining h yields h (0 * 37 + h = h).
Combining an empty hash into an empty hash leaves the result empty (0 * 37 + 0 = 0). Consequently, accumulating any number of empty hashes remains an empty hash.

◆ load()

bool ultra::hash_t::load ( std::istream & in)
Parameters
[in]ininput stream
Returns
true if hash_t loaded correctly
Note
If the load operation isn't successful the current hash_t isn't changed.

◆ save()

bool ultra::hash_t::save ( std::ostream & out) const
Parameters
[out]outoutput stream
Returns
true if hash_t was saved correctly

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