HavoqGT
havoqgt::detail Namespace Reference

Classes

class  basic_nullbuf
 
class  basic_onullstream
 
class  preferential_attachment_helper
 
class  reservable_priority_queue
 

Functions

uint32_t hash32 (uint32_t a)
 
uint16_t hash16 (uint16_t a)
 
uint64_t shifted_n_hash32 (uint64_t input, int n)
 
uint64_t shifted_n_hash16 (uint64_t input, int n)
 
uint64_t hash_nbits (uint64_t input, int n)
 
std::ostream & get_null_ostream ()
 
environment *& priv_havoqgt_env ()
 

Function Documentation

std::ostream& havoqgt::detail::get_null_ostream ( )
inline

Definition at line 85 of file null_ostream.hpp.

85  {
86  static basic_onullstream<char> null_ostream;
87  return null_ostream;
88 }

Here is the caller graph for this function:

uint16_t havoqgt::detail::hash16 ( uint16_t  a)
inline

Definition at line 76 of file hash.hpp.

77 {
78  a = (a+0x5d16) + (a<<6);
79  a = (a^0xc23c) ^ (a>>9);
80  a = (a+0x67b1) + (a<<5);
81  a = (a+0x646c) ^ (a<<7);
82  a = (a+0x46c5) + (a<<3);
83  a = (a^0x4f09) ^ (a>>8);
84  return a;
85 }

Here is the caller graph for this function:

uint32_t havoqgt::detail::hash32 ( uint32_t  a)
inline

Hash functions

Todo:

requires documentation!

requires testing!

Definition at line 65 of file hash.hpp.

66 {
67  a = (a+0x7ed55d16) + (a<<12);
68  a = (a^0xc761c23c) ^ (a>>19);
69  a = (a+0x165667b1) + (a<<5);
70  a = (a+0xd3a2646c) ^ (a<<9);
71  a = (a+0xfd7046c5) + (a<<3);
72  a = (a^0xb55a4f09) ^ (a>>16);
73  return a;
74 }

Here is the caller graph for this function:

uint64_t havoqgt::detail::hash_nbits ( uint64_t  input,
int  n 
)
inline

Definition at line 115 of file hash.hpp.

115  {
116  //std::cout << "hash_nbits(" << input << ", " << n << ") = ";
117  if(n==32) {
118  input = hash32(input);
119  } else if(n>32){
120  assert(n>32);
121  n -= 32;
122  for(int i=0; i<=n; ++i) {
123  input = shifted_n_hash32(input, i);
124  }
125  for(int i=n; i>=0; --i) {
126  input = shifted_n_hash32(input, i);
127  }
128  } else if(n<32) {
129  assert(n<32);
130  assert(n>16 && "Hashing less than 16bits is not supported");
131  n -= 16;
132  for(int i=0; i<=n; ++i) {
133  input = shifted_n_hash16(input, i);
134  }
135  for(int i=n; i>=0; --i) {
136  input = shifted_n_hash16(input, i);
137  }
138  }
139  //std::cout << input << std::endl;
140  return input;
141 }
uint64_t shifted_n_hash16(uint64_t input, int n)
Definition: hash.hpp:101
uint32_t hash32(uint32_t a)
Definition: hash.hpp:65
uint64_t shifted_n_hash32(uint64_t input, int n)
Definition: hash.hpp:87

Here is the call graph for this function:

Here is the caller graph for this function:

environment*& havoqgt::detail::priv_havoqgt_env ( )
inline

Definition at line 236 of file environment.hpp.

236  {
237  static environment* penv;
238  return penv;
239  }

Here is the caller graph for this function:

uint64_t havoqgt::detail::shifted_n_hash16 ( uint64_t  input,
int  n 
)
inline

Definition at line 101 of file hash.hpp.

101  {
102  uint64_t to_hash = input >> n;
103  uint64_t mask = 0xFFFF;
104  to_hash &= mask;
105  to_hash = hash16(to_hash);
106 
107  to_hash <<= n;
108  mask <<= n;
109  //clear bits
110  input &= ~mask;
111  input |= to_hash;
112  return input;
113 }
uint16_t hash16(uint16_t a)
Definition: hash.hpp:76

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t havoqgt::detail::shifted_n_hash32 ( uint64_t  input,
int  n 
)
inline

Definition at line 87 of file hash.hpp.

87  {
88  uint64_t to_hash = input >> n;
89  uint64_t mask = 0xFFFFFFFF;
90  to_hash &= mask;
91  to_hash = hash32(to_hash);
92 
93  to_hash <<= n;
94  mask <<= n;
95  //clear bits
96  input &= ~mask;
97  input |= to_hash;
98  return input;
99 }
uint32_t hash32(uint32_t a)
Definition: hash.hpp:65

Here is the call graph for this function:

Here is the caller graph for this function: