AGX Dynamics  2.35.0.1
lookup3.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 /*
18 This source code has been taken and modified by Algoryx Simulation AB
19 from the source and under the license given below.
20 */
21 
22 /*
23 -------------------------------------------------------------------------------
24 lookup3.c, by Bob Jenkins, May 2006, Public Domain.
25 
26 These are functions for producing 32-bit hashes for hash table lookup.
27 hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
28 are externally useful functions. Routines to test the hash are included
29 if SELF_TEST is defined. You can use this free for any purpose. It's in
30 the public domain. It has no warranty.
31 
32 You probably want to use hashlittle(). hashlittle() and hashbig()
33 hash byte arrays. hashlittle() is is faster than hashbig() on
34 little-endian machines. Intel and AMD are little-endian machines.
35 On second thought, you probably want hashlittle2(), which is identical to
36 hashlittle() except it returns two 32-bit hashes for the price of one.
37 You could implement hashbig2() if you wanted but I haven't bothered here.
38 
39 If you want to find a hash of, say, exactly 7 integers, do
40  a = i1; b = i2; c = i3;
41  mix(a,b,c);
42  a += i4; b += i5; c += i6;
43  mix(a,b,c);
44  a += i7;
45  final(a,b,c);
46 then use c as the hash value. If you have a variable length array of
47 4-byte integers to hash, use hashword(). If you have a byte array (like
48 a character string), use hashlittle(). If you have several byte arrays, or
49 a mix of things, see the comments above hashlittle().
50 
51 Why is this so big? I read 12 bytes at a time into 3 4-byte integers,
52 then mix those integers. This is fast (you can do a lot more thorough
53 mixing with 12*3 instructions on 3 integers than you can with 3 instructions
54 on 1 byte), but shoehorning those bytes into integers efficiently is messy.
55 -------------------------------------------------------------------------------
56 */
57 
58 #ifndef AGX_LOOKUP3_H
59 #define AGX_LOOKUP3_H
60 
61 
62 #include <agx/agx.h>
63 #include <agx/Math.h>
64 #include <agx/agxPhysics_export.h>
65 
66 namespace agx {
67 
82  const uint32_t *k, /* the key, an array of uint32_t values */
83  size_t length, /* the length of the key, in uint32_ts */
84  uint32_t initval) ; /* the previous hash, or an arbitrary value */
85 
86 
87 
97  const uint32_t *k, /* the key, an array of uint32_t values */
98  size_t length, /* the length of the key, in uint32_ts */
99  uint32_t *pc, /* IN: seed OUT: primary hash value */
100  uint32_t *pb); /* IN: more seed OUT: secondary hash value */
101 
102 }
103 
104 
105 #endif
#define AGXPHYSICS_EXPORT
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AGXPHYSICS_EXPORT void hashword2(const uint32_t *k, size_t length, uint32_t *pc, uint32_t *pb)
AGXPHYSICS_EXPORT uint32_t hashword(const uint32_t *k, size_t length, uint32_t initval)