mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 21:41:20 +02:00
Add a hash_combine function for mixing hash values.
This hash function is derived from Boost's function of the same name. Author: Andres Freund, Thomas Munro Discussion: https://postgr.es/m/CAEepm%3D3rdgjfxW4cKvJ0OEmya2-34B0qHNG1xV0vK7TGPJGMUQ%40mail.gmail.com Discussion: https://postgr.es/m/20170731210844.3cwrkmsmbbpt4rjc%40alap3.anarazel.de
This commit is contained in:
parent
2bfd1b1ee5
commit
0052a0243d
23
src/include/utils/hashutils.h
Normal file
23
src/include/utils/hashutils.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Utilities for working with hash values.
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 2017, PostgreSQL Global Development Group
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HASHUTILS_H
|
||||||
|
#define HASHUTILS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Combine two hash values, resulting in another hash value, with decent bit
|
||||||
|
* mixing.
|
||||||
|
*
|
||||||
|
* Similar to boost's hash_combine().
|
||||||
|
*/
|
||||||
|
static inline uint32
|
||||||
|
hash_combine(uint32 a, uint32 b)
|
||||||
|
{
|
||||||
|
a ^= b + 0x9e3779b9 + (a << 6) + (a >> 2);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HASHUTILS_H */
|
Loading…
Reference in New Issue
Block a user