Main MRPT website > C++ reference for MRPT 1.5.6
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
const GLfloat * c
Definition: glew.h:10088
#define SELBYTE3(v)
unsigned char uint8_t
Definition: rptypes.h:43
GLsizei const GLfloat * value
Definition: glew.h:1756
#define SELBYTE0(v)
#define SELBYTE2(v)
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
GLsizei const GLcharARB ** string
Definition: glew.h:3293
#define SELBYTE1(v)
unsigned __int32 uint32_t
Definition: rptypes.h:49
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018