Main MRPT website > C++ reference for MRPT 1.5.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 = ((SELBYTE0(hash) ^ SELBYTE1(hash)) ^ SELBYTE2(hash)) ^ SELBYTE3(hash);
32 }
34 {
35  uint64_t hash;
36  reduced_hash(value, hash);
37  out_hash = MAKEWORD16B( SELBYTE0(hash) ^ SELBYTE1(hash), SELBYTE2(hash) ^ SELBYTE3(hash) );
38 }
39 
41 {
42  uint64_t hash;
43  reduced_hash(value, hash);
44  out_hash = (hash & 0xffffffff) ^ ((hash >> 32) & 0xffffffff);
45 }
46 
47 
unsigned __int16 uint16_t
Definition: rptypes.h:46
#define SELBYTE3(v)
unsigned char uint8_t
Definition: rptypes.h:43
#define SELBYTE0(v)
const GLubyte * c
Definition: glext.h:5590
#define SELBYTE2(v)
GLsizei const GLchar ** string
Definition: glext.h:3919
void BASE_IMPEXP reduced_hash(const std::string &value, uint8_t &hash)
hash function used by ts_hash_map. Uses dbj2 method
Definition: ts_hash_map.cpp:27
unsigned __int64 uint64_t
Definition: rptypes.h:52
#define SELBYTE1(v)
GLsizei const GLfloat * value
Definition: glext.h:3929
unsigned __int32 uint32_t
Definition: rptypes.h:49
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020