Main MRPT website > C++ reference for MRPT 1.9.9
ts_hash_map.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/utils/ts_hash_map.h>
13 #include <mrpt/utils/bits.h>
14 #include <cstring>
15 #include <cstdlib>
16 
18 {
19  // dbj2 method:
20  uint64_t hash = 5381;
21  const char* str = value.c_str();
22  int c;
23  while ((c = *str++) != 0)
24  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
25  out_hash = hash;
26 }
28 {
29  uint64_t hash;
30  reduced_hash(value, hash);
31  out_hash =
32  ((SELBYTE0(hash) ^ SELBYTE1(hash)) ^ SELBYTE2(hash)) ^ SELBYTE3(hash);
33 }
35 {
36  uint64_t hash;
37  reduced_hash(value, hash);
38  out_hash = MAKEWORD16B(
39  SELBYTE0(hash) ^ SELBYTE1(hash), SELBYTE2(hash) ^ SELBYTE3(hash));
40 }
41 
43 {
44  uint64_t hash;
45  reduced_hash(value, hash);
46  out_hash = (hash & 0xffffffff) ^ ((hash >> 32) & 0xffffffff);
47 }
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)
Definition: bits.h:284
#define SELBYTE1(v)
Definition: bits.h:280
#define SELBYTE3(v)
Definition: bits.h:282
#define SELBYTE0(v)
Definition: bits.h:279
#define SELBYTE2(v)
Definition: bits.h:281
const GLubyte * c
Definition: glext.h:6313
GLsizei const GLfloat * value
Definition: glext.h:4117
GLsizei const GLchar ** string
Definition: glext.h:4101
void reduced_hash(const std::string &value, uint8_t &hash)
hash function used by ts_hash_map.
Definition: ts_hash_map.cpp:27
unsigned __int16 uint16_t
Definition: rptypes.h:44
unsigned __int32 uint32_t
Definition: rptypes.h:47
unsigned char uint8_t
Definition: rptypes.h:41
unsigned __int64 uint64_t
Definition: rptypes.h:50



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 63ea9d1f1 Thu Nov 23 00:06:53 2017 +0100 at mar 26 may 2026 12:19:29 CEST