template <typename H>

class HashStateBase

Defined at line 213 of file ../../third_party/abseil-cpp/absl/hash/internal/hash.h

HashStateBase

An internal implementation detail that contains common implementation details

for all of the "hash state objects" objects generated by Abseil. This is not

a public API; users should not create classes that inherit from this.

A hash state object is the template argument `H` passed to `AbslHashValue`.

It represents an intermediate state in the computation of an unspecified hash

algorithm. `HashStateBase` provides a CRTP style base class for hash state

implementations. Developers adding type support for `absl::Hash` should not

rely on any parts of the state object other than the following member

functions:

* HashStateBase::combine()

* HashStateBase::combine_contiguous()

* HashStateBase::combine_unordered()

A derived hash state class of type `H` must provide a public member function

with a signature similar to the following:

`static H combine_contiguous(H state, const unsigned char*, size_t)`.

It must also provide a private template method named RunCombineUnordered.

A "consumer" is a 1-arg functor returning void. Its argument is a reference

to an inner hash state object, and it may be called multiple times. When

called, the functor consumes the entropy from the provided state object,

and resets that object to its empty state.

A "combiner" is a stateless 2-arg functor returning void. Its arguments are

an inner hash state object and an ElementStateConsumer functor. A combiner

uses the provided inner hash state object to hash each element of the

container, passing the inner hash state object to the consumer after hashing

each element.

Given these definitions, a derived hash state class of type H

must provide a private template method with a signature similar to the

following:

`template

<typename

CombinerT>`

`static H RunCombineUnordered(H outer_state, CombinerT combiner)`

This function is responsible for constructing the inner state object and

providing a consumer to the combiner. It uses side effects of the consumer

and combiner to mix the state of each element in an order-independent manner,

and uses this to return an updated value of `outer_state`.

This inside-out approach generates efficient object code in the normal case,

but allows us to use stack storage to implement the absl::HashState type

erasure mechanism (avoiding heap allocations while hashing).

`HashStateBase` will provide a complete implementation for a hash state

object in terms of these two methods.

Example:

// Use CRTP to define your derived class.

struct MyHashState : HashStateBase

<MyHashState

> {

static H combine_contiguous(H state, const unsigned char*, size_t);

using MyHashState::HashStateBase::combine;

using MyHashState::HashStateBase::combine_contiguous;

using MyHashState::HashStateBase::combine_unordered;

private:

template

<typename

CombinerT>

static H RunCombineUnordered(H state, CombinerT combiner);

};

Public Methods

H combine (H state)

Defined at line 234 of file ../../third_party/abseil-cpp/absl/hash/internal/hash.h

template <typename T, typename... Ts>
H combine (H state, const T & value, const Ts &... values)

HashStateBase::combine()

Combines an arbitrary number of values into a hash state, returning the

updated state.

Each of the value types `T` must be separately hashable by the Abseil

hashing framework.

NOTE:

state = H::combine(std::move(state), value1, value2, value3);

is guaranteed to produce the same hash expansion as:

state = H::combine(std::move(state), value1);

state = H::combine(std::move(state), value2);

state = H::combine(std::move(state), value3);

Defined at line 1308 of file ../../third_party/abseil-cpp/absl/hash/internal/hash.h

template <typename T>
H combine_contiguous (H state, const T * data, size_t size)

HashStateBase::combine_contiguous()

Defined at line 1317 of file ../../third_party/abseil-cpp/absl/hash/internal/hash.h

template <typename I>
H combine_unordered (H state, I begin, I end)

HashStateBase::combine_unordered()

Defined at line 1324 of file ../../third_party/abseil-cpp/absl/hash/internal/hash.h

Records