#include <string.h>
#include "Hash.h"
Go to the source code of this file.
◆ HashForBytes()
int HashForBytes |
( |
int |
hash, |
|
|
const uint8_t * |
bytes, |
|
|
const Range |
range |
|
) |
| |
Accumulates the hash value of bytes
into hash
.
- Parameters
-
hash | The hash accumulator. |
bytes | The bytes to hash. |
range | The Range to hash. |
- Returns
- The accumulated hash value.
Definition at line 28 of file Hash.c.
28 {
29
31
32 int shift;
33 if (i & 1) {
34 shift = 16 + (i % 16);
35 } else {
36 shift = (i % 16);
37 }
38
39 hash += 31 * ((int) bytes[i]) << shift;
40 }
41
43}
int hash(const Object *self)
ssize_t location
The location.
◆ HashForCharacters()
int HashForCharacters |
( |
int |
hash, |
|
|
const char * |
chars, |
|
|
const Range |
range |
|
) |
| |
Accumulates the hash value of chars
into hash
.
- Parameters
-
hash | The hash accumulator. |
chars | The characters to hash. |
range | The Range to hash. |
- Returns
- The accumulated hash value.
Definition at line 45 of file Hash.c.
45 {
47}
int HashForBytes(int hash, const uint8_t *bytes, const Range range)
Accumulates the hash value of bytes into hash.
◆ HashForCString()
int HashForCString |
( |
int |
hash, |
|
|
const char * |
chars |
|
) |
| |
Accumulates the hash value of the null-terminated string
into hash
.
- Parameters
-
hash | The hash accumulator. |
chars | The null-terminated C string. |
- Returns
- The accumulated hash value.
Definition at line 49 of file Hash.c.
49 {
50
51 if (string) {
53 }
54
55 return 0;
56}
int HashForCharacters(int hash, const char *chars, const Range range)
Accumulates the hash value of chars into hash.
A location and length into contiguous collections.
◆ HashForDecimal()
int HashForDecimal |
( |
int |
hash, |
|
|
const double |
decimal |
|
) |
| |
Accumulates the hash value of decimal
into hash
.
- Parameters
-
hash | The hash accumulator. |
decimal | The decimal to hash. |
- Returns
- The accumulated hash value.
Definition at line 58 of file Hash.c.
58 {
59 return hash + 31 * (int) decimal;
60}
◆ HashForInteger()
int HashForInteger |
( |
int |
hash, |
|
|
const long |
integer |
|
) |
| |
Accumulates the hash value of integer
into hash
.
- Parameters
-
hash | The hash accumulator. |
integer | The integer to hash. |
- Returns
- The accumulated hash value.
Definition at line 62 of file Hash.c.
62 {
63 return hash + 31 * (int) integer;
64}
◆ HashForObject()
int HashForObject |
( |
int |
hash, |
|
|
const ident |
obj |
|
) |
| |
Accumulates the hash value of object
into hash
.
- Parameters
-
hash | The hash accumulator. |
obj | The Object to hash. |
- Returns
- The accumulated hash value.
Definition at line 66 of file Hash.c.
66 {
67
70 }
71
72 return 0;
73}
#define cast(type, obj)
Safely cast obj to type.
Object is the root Class of The Objectively Class hierarchy.