AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
lookup3.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17/*
18This source code has been taken and modified by Algoryx Simulation AB
19from the source and under the license given below.
20*/
21
22/*
23-------------------------------------------------------------------------------
24lookup3.c, by Bob Jenkins, May 2006, Public Domain.
25
26These are functions for producing 32-bit hashes for hash table lookup.
27hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
28are externally useful functions. Routines to test the hash are included
29if SELF_TEST is defined. You can use this free for any purpose. It's in
30the public domain. It has no warranty.
31
32You probably want to use hashlittle(). hashlittle() and hashbig()
33hash byte arrays. hashlittle() is is faster than hashbig() on
34little-endian machines. Intel and AMD are little-endian machines.
35On second thought, you probably want hashlittle2(), which is identical to
36hashlittle() except it returns two 32-bit hashes for the price of one.
37You could implement hashbig2() if you wanted but I haven't bothered here.
38
39If 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);
46then use c as the hash value. If you have a variable length array of
474-byte integers to hash, use hashword(). If you have a byte array (like
48a character string), use hashlittle(). If you have several byte arrays, or
49a mix of things, see the comments above hashlittle().
50
51Why is this so big? I read 12 bytes at a time into 3 4-byte integers,
52then mix those integers. This is fast (you can do a lot more thorough
53mixing with 12*3 instructions on 3 integers than you can with 3 instructions
54on 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>
65
66namespace 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)