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 }
unsigned __int16 uint16_t
Definition: rptypes.h:44
unsigned char uint8_t
Definition: rptypes.h:41
const GLubyte * c
Definition: glext.h:6313
void reduced_hash(const std::string &value, uint8_t &hash)
hash function used by ts_hash_map.
Definition: ts_hash_map.cpp:28
#define SELBYTE0(v)
Definition: byte_manip.h:11
GLsizei const GLchar ** string
Definition: glext.h:4101
#define SELBYTE1(v)
Definition: byte_manip.h:12
unsigned __int64 uint64_t
Definition: rptypes.h:50
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)
Definition: byte_manip.h:16
GLsizei const GLfloat * value
Definition: glext.h:4117
#define SELBYTE3(v)
Definition: byte_manip.h:14
unsigned __int32 uint32_t
Definition: rptypes.h:47
#define SELBYTE2(v)
Definition: byte_manip.h:13



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020