city-hash.cpp File Reference
#include "city-hash.hpp"
#include <algorithm>
#include <string.h>
#include <byteswap.h>
+ Include dependency graph for city-hash.cpp:

Go to the source code of this file.

Macros

#define LIKELY(x)   (x)
 
#define PERMUTE3(a, b, c)   do { std::swap(a, b); std::swap(a, c); } while (0)
 
#define uint32_in_expected_order(x)   (x)
 
#define uint64_in_expected_order(x)   (x)
 

Functions

uint128 CityHash128 (const char *s, size_t len)
 
uint128 CityHash128WithSeed (const char *s, size_t len, uint128 seed)
 
uint32 CityHash32 (const char *s, size_t len)
 
uint64 CityHash64 (const char *s, size_t len)
 
uint64 CityHash64WithSeed (const char *s, size_t len, uint64 seed)
 
uint64 CityHash64WithSeeds (const char *s, size_t len, uint64 seed0, uint64 seed1)
 
static uint128 CityMurmur (const char *s, size_t len, uint128 seed)
 
static uint32 Fetch32 (const char *p)
 
static uint64 Fetch64 (const char *p)
 
static uint32 fmix (uint32 h)
 
static uint32 Hash32Len0to4 (const char *s, size_t len)
 
static uint32 Hash32Len13to24 (const char *s, size_t len)
 
static uint32 Hash32Len5to12 (const char *s, size_t len)
 
static uint64 HashLen0to16 (const char *s, size_t len)
 
static uint64 HashLen16 (uint64 u, uint64 v)
 
static uint64 HashLen16 (uint64 u, uint64 v, uint64 mul)
 
static uint64 HashLen17to32 (const char *s, size_t len)
 
static uint64 HashLen33to64 (const char *s, size_t len)
 
static uint32 Mur (uint32 a, uint32 h)
 
static uint64 Rotate (uint64 val, int shift)
 
static uint32 Rotate32 (uint32 val, int shift)
 
static uint64 ShiftMix (uint64 val)
 
static uint32 UNALIGNED_LOAD32 (const char *p)
 
static uint64 UNALIGNED_LOAD64 (const char *p)
 
static pair< uint64, uint64WeakHashLen32WithSeeds (const char *s, uint64 a, uint64 b)
 
static pair< uint64, uint64WeakHashLen32WithSeeds (uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b)
 

Variables

static const uint32_t c1 = 0xcc9e2d51
 
static const uint32_t c2 = 0x1b873593
 
static const uint64 k0 = 0xc3a5c85c97cb3127ULL
 
static const uint64 k1 = 0xb492b66fbe98f273ULL
 
static const uint64 k2 = 0x9ae16a3b2f90404fULL
 

Macro Definition Documentation

◆ LIKELY

#define LIKELY (   x)    (x)

Definition at line 101 of file city-hash.cpp.

◆ PERMUTE3

#define PERMUTE3 (   a,
  b,
 
)    do { std::swap(a, b); std::swap(a, c); } while (0)

Definition at line 139 of file city-hash.cpp.

◆ uint32_in_expected_order

#define uint32_in_expected_order (   x)    (x)

Definition at line 93 of file city-hash.cpp.

◆ uint64_in_expected_order

#define uint64_in_expected_order (   x)    (x)

Definition at line 94 of file city-hash.cpp.

Function Documentation

◆ CityHash128()

uint128 CityHash128 ( const char *  s,
size_t  len 
)

Definition at line 501 of file city-hash.cpp.

◆ CityHash128WithSeed()

uint128 CityHash128WithSeed ( const char *  s,
size_t  len,
uint128  seed 
)

Definition at line 438 of file city-hash.cpp.

◆ CityHash32()

uint32 CityHash32 ( const char *  s,
size_t  len 
)

Definition at line 182 of file city-hash.cpp.

◆ CityHash64()

uint64 CityHash64 ( const char *  s,
size_t  len 
)

Definition at line 359 of file city-hash.cpp.

◆ CityHash64WithSeed()

uint64 CityHash64WithSeed ( const char *  s,
size_t  len,
uint64  seed 
)

Definition at line 397 of file city-hash.cpp.

◆ CityHash64WithSeeds()

uint64 CityHash64WithSeeds ( const char *  s,
size_t  len,
uint64  seed0,
uint64  seed1 
)

Definition at line 401 of file city-hash.cpp.

◆ CityMurmur()

static uint128 CityMurmur ( const char *  s,
size_t  len,
uint128  seed 
)
static

Definition at line 408 of file city-hash.cpp.

◆ Fetch32()

static uint32 Fetch32 ( const char *  p)
static

Definition at line 109 of file city-hash.cpp.

◆ Fetch64()

static uint64 Fetch64 ( const char *  p)
static

Definition at line 105 of file city-hash.cpp.

◆ fmix()

static uint32 fmix ( uint32  h)
static

Definition at line 123 of file city-hash.cpp.

◆ Hash32Len0to4()

static uint32 Hash32Len0to4 ( const char *  s,
size_t  len 
)
static

Definition at line 163 of file city-hash.cpp.

◆ Hash32Len13to24()

static uint32 Hash32Len13to24 ( const char *  s,
size_t  len 
)
static

Definition at line 151 of file city-hash.cpp.

◆ Hash32Len5to12()

static uint32 Hash32Len5to12 ( const char *  s,
size_t  len 
)
static

Definition at line 174 of file city-hash.cpp.

◆ HashLen0to16()

static uint64 HashLen0to16 ( const char *  s,
size_t  len 
)
static

Definition at line 276 of file city-hash.cpp.

◆ HashLen16() [1/2]

static uint64 HashLen16 ( uint64  u,
uint64  v 
)
static

Definition at line 262 of file city-hash.cpp.

◆ HashLen16() [2/2]

static uint64 HashLen16 ( uint64  u,
uint64  v,
uint64  mul 
)
static

Definition at line 266 of file city-hash.cpp.

◆ HashLen17to32()

static uint64 HashLen17to32 ( const char *  s,
size_t  len 
)
static

Definition at line 303 of file city-hash.cpp.

◆ HashLen33to64()

static uint64 HashLen33to64 ( const char *  s,
size_t  len 
)
static

Definition at line 338 of file city-hash.cpp.

◆ Mur()

static uint32 Mur ( uint32  a,
uint32  h 
)
static

Definition at line 141 of file city-hash.cpp.

◆ Rotate()

static uint64 Rotate ( uint64  val,
int  shift 
)
static

Definition at line 253 of file city-hash.cpp.

◆ Rotate32()

static uint32 Rotate32 ( uint32  val,
int  shift 
)
static

Definition at line 133 of file city-hash.cpp.

◆ ShiftMix()

static uint64 ShiftMix ( uint64  val)
static

Definition at line 258 of file city-hash.cpp.

◆ UNALIGNED_LOAD32()

static uint32 UNALIGNED_LOAD32 ( const char *  p)
static

Definition at line 44 of file city-hash.cpp.

◆ UNALIGNED_LOAD64()

static uint64 UNALIGNED_LOAD64 ( const char *  p)
static

Definition at line 38 of file city-hash.cpp.

◆ WeakHashLen32WithSeeds() [1/2]

static pair<uint64, uint64> WeakHashLen32WithSeeds ( const char *  s,
uint64  a,
uint64  b 
)
static

Definition at line 327 of file city-hash.cpp.

◆ WeakHashLen32WithSeeds() [2/2]

static pair<uint64, uint64> WeakHashLen32WithSeeds ( uint64  w,
uint64  x,
uint64  y,
uint64  z,
uint64  a,
uint64  b 
)
static

Definition at line 315 of file city-hash.cpp.

Variable Documentation

◆ c1

const uint32_t c1 = 0xcc9e2d51
static

Definition at line 119 of file city-hash.cpp.

◆ c2

const uint32_t c2 = 0x1b873593
static

Definition at line 120 of file city-hash.cpp.

◆ k0

const uint64 k0 = 0xc3a5c85c97cb3127ULL
static

Definition at line 114 of file city-hash.cpp.

◆ k1

const uint64 k1 = 0xb492b66fbe98f273ULL
static

Definition at line 115 of file city-hash.cpp.

◆ k2

const uint64 k2 = 0x9ae16a3b2f90404fULL
static

Definition at line 116 of file city-hash.cpp.