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-2018, 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 "containers-precomp.h" // Precompiled headers
11 
13 #include <mrpt/core/byte_manip.h> // MAKEWORD16B(), etc.
14 #include <cstring>
15 #include <cstdlib>
16 
18  const std::string& value, uint64_t& out_hash)
19 {
20  // dbj2 method:
21  uint64_t hash = 5381;
22  const char* str = value.c_str();
23  int c;
24  while ((c = *str++) != 0)
25  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
26  out_hash = hash;
27 }
29 {
30  uint64_t hash;
31  reduced_hash(value, hash);
32  out_hash =
33  ((SELBYTE0(hash) ^ SELBYTE1(hash)) ^ SELBYTE2(hash)) ^ SELBYTE3(hash);
34 }
36  const std::string& value, uint16_t& out_hash)
37 {
38  uint64_t hash;
39  reduced_hash(value, hash);
40  out_hash = MAKEWORD16B(
41  SELBYTE0(hash) ^ SELBYTE1(hash), SELBYTE2(hash) ^ SELBYTE3(hash));
42 }
43 
45  const std::string& value, uint32_t& out_hash)
46 {
47  uint64_t hash;
48  reduced_hash(value, hash);
49  out_hash = (hash & 0xffffffff) ^ ((hash >> 32) & 0xffffffff);
50 }
byte_manip.h
uint16_t
unsigned __int16 uint16_t
Definition: rptypes.h:44
MAKEWORD16B
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)
Definition: byte_manip.h:16
c
const GLubyte * c
Definition: glext.h:6313
SELBYTE0
#define SELBYTE0(v)
Definition: byte_manip.h:11
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
SELBYTE2
#define SELBYTE2(v)
Definition: byte_manip.h:13
SELBYTE1
#define SELBYTE1(v)
Definition: byte_manip.h:12
ts_hash_map.h
mrpt::containers::reduced_hash
void reduced_hash(const std::string &value, uint8_t &hash)
hash function used by ts_hash_map.
Definition: ts_hash_map.cpp:28
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
SELBYTE3
#define SELBYTE3(v)
Definition: byte_manip.h:14
value
GLsizei const GLfloat * value
Definition: glext.h:4117
containers-precomp.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST