#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
30 unsigned int uhash = (
unsigned int)
hash;
31
33
34 int shift;
35 if (i & 1) {
36 shift = 16 + (i % 16);
37 } else {
38 shift = (i % 16);
39 }
40
41 uhash += 31U * ((unsigned int) bytes[i]) << shift;
42 }
43
44 return (int) uhash;
45}
static 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 47 of file Hash.c.
47 {
49}
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 51 of file Hash.c.
51 {
52
53 if (string) {
55 }
56
57 return 0;
58}
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 60 of file Hash.c.
60 {
61 unsigned int uhash = (
unsigned int)
hash;
62 uhash += 31U * (unsigned int) decimal;
63 return (int) uhash;
64}
◆ 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 66 of file Hash.c.
66 {
67 unsigned int uhash = (
unsigned int)
hash;
68 uhash += 31U * (unsigned int) integer;
69 return (int) uhash;
70}
◆ 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 72 of file Hash.c.
72 {
73
75 unsigned int uhash = (
unsigned int)
hash;
77 return (int) uhash;
78 }
79
80 return 0;
81}
#define cast(type, obj)
Safely cast obj to type.
Object is the root Class of The Objectively Class hierarchy.