Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::bop::NonOrderedSetHasher< IntType > Class Template Reference

#include <bop_ls.h>

Public Member Functions

 NonOrderedSetHasher (absl::BitGenRef random)
 
void Initialize (int size)
 Initializes the NonOrderedSetHasher to hash sets of integer in [0, n).
 
void IgnoreElement (IntType e)
 
uint64_t Hash (const std::vector< IntType > &set) const
 
uint64_t Hash (IntType e) const
 
bool IsInitialized () const
 Returns true if Initialize() has been called with a non-zero size.
 

Detailed Description

template<typename IntType>
class operations_research::bop::NonOrderedSetHasher< IntType >

A simple and efficient class to hash a given set of integers in [0, n). It uses O(n) memory and produces a good hash (random linear function).

Definition at line 221 of file bop_ls.h.

Constructor & Destructor Documentation

◆ NonOrderedSetHasher()

template<typename IntType >
operations_research::bop::NonOrderedSetHasher< IntType >::NonOrderedSetHasher ( absl::BitGenRef random)
inlineexplicit

Definition at line 223 of file bop_ls.h.

Member Function Documentation

◆ Hash() [1/2]

template<typename IntType >
uint64_t operations_research::bop::NonOrderedSetHasher< IntType >::Hash ( const std::vector< IntType > & set) const
inline

Returns the hash of the given set. The hash is independent of the set order, but there must be no duplicate element in the set. This uses a simple random linear function which has really good hashing properties.

Definition at line 240 of file bop_ls.h.

◆ Hash() [2/2]

template<typename IntType >
uint64_t operations_research::bop::NonOrderedSetHasher< IntType >::Hash ( IntType e) const
inline

The hash of a set is simply the XOR of all its elements. This allows to compute an hash incrementally or without the need of a vector<>.

Definition at line 248 of file bop_ls.h.

◆ IgnoreElement()

template<typename IntType >
void operations_research::bop::NonOrderedSetHasher< IntType >::IgnoreElement ( IntType e)
inline

Ignores the given set element in all subsequent hash computation. Note that this will be reset by the next call to Initialize().

Definition at line 235 of file bop_ls.h.

◆ Initialize()

template<typename IntType >
void operations_research::bop::NonOrderedSetHasher< IntType >::Initialize ( int size)
inline

Initializes the NonOrderedSetHasher to hash sets of integer in [0, n).

Definition at line 226 of file bop_ls.h.

◆ IsInitialized()

template<typename IntType >
bool operations_research::bop::NonOrderedSetHasher< IntType >::IsInitialized ( ) const
inline

Returns true if Initialize() has been called with a non-zero size.

Definition at line 251 of file bop_ls.h.


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