28 inline unsigned int newHash(
unsigned int x) {
29 x = ((x >> 16) ^ x) * 0x45d9f3b;
30 x = ((x >> 16) ^ x) * 0x45d9f3b;
36 inline size_t hashMe(
char* me,
size_t len) {
39 for (
int i = 0; i < len; i += 8) {
44 for (
int j = 0; j < 4; j++) {
46 low += (me[i + j] & 0xFF) << (8 * j);
48 low += 123 << (8 * j);
55 for (
int j = 4; j < 8; j++) {
57 high += (me[i + j] & 0xFF) << (8 * (j - 3));
59 high += 97 << (8 * (j - 3));
64 size_t returnVal = ((size_t)
newHash(high)) << 32;
65 returnVal +=
newHash(low) & 0xFFFFFFFF;
66 code = code ^ returnVal;
69 for (
int i = 0; i < len; i++) {
70 code = 31 * code + me[i];
77 template <
class KeyType,
class ValueType>
81 std::cout <<
"Fatal Error: Map initialization:" << initSize
82 <<
" too small; must be at least one.\n";
90 myArray = makeObjectWithExtraStorage<PairArray<KeyType, ValueType>>(size * initSize, initSize);
93 template <
class KeyType,
class ValueType>
98 myArray = makeObjectWithExtraStorage<PairArray<KeyType, ValueType>>(size * 2, 2);
101 template <
class KeyType,
class ValueType>
105 template <
class KeyType,
class ValueType>
107 myArray->setUnused(clearMe);
111 template <
class KeyType,
class ValueType>
118 if (myArray->count(which) == 0) {
119 if (myArray->isOverFull()) {
124 ValueType& res = (*myArray)[which];
128 template <
class KeyType,
class ValueType>
130 return myArray->count(which);
133 template <
class KeyType,
class ValueType>
135 return myArray->numUsedSlots();
138 template <
class KeyType,
class ValueType>
144 template <
class KeyType,
class ValueType>
151 template <
class KeyType,
class ValueType>
ValueType & operator[](const KeyType &which)
Handle< PairArray< KeyType, ValueType > > & getArray()
int count(const KeyType &which)
size_t hashMe(char *me, size_t len)
unsigned int newHash(unsigned int x)
void setUnused(const KeyType &clearMe)
PDBMapIterator< KeyType, ValueType > begin()
PDBMapIterator< KeyType, ValueType > end()