bool SWLD::hasEntry(SWKey const * key_) const { auto const keyText = key_->getText(); if (m_strongsPadding) { auto const buf(strongsPadBuf(keyText.c_str())); return buf.get() == getKeyForEntry(getEntryForKey(buf.get())); } else { return keyText == getKeyForEntry(getEntryForKey(keyText.c_str())); } }
unsigned * SNAPHashTable::SlowLookup(unsigned key) { Entry *entry = getEntryForKey(key); if (NULL == entry || entry->value1 == 0xffffffff) { return NULL; } return &entry->value1; }
SNAPHashTable::ValueType * SNAPHashTable::SlowLookup(KeyType key) { void *entry = getEntryForKey(key); if (NULL == entry || doesEntryHaveInvalidValue(entry)) { return NULL; } return (ValueType *)entry; }
bool SNAPHashTable::Insert(KeyType key, ValueType *data) { void *entry = getEntryForKey(key); if (NULL == entry) { return false; } setKey(entry, key); for (unsigned i = 0; i < valueCount; i++) { memcpy((char *)entry + i * valueSizeInBytes, &data[i], valueSizeInBytes); // Assumes little endian } return true; }
bool SNAPHashTable::Insert(unsigned key, const unsigned *data) { _ASSERT(data[0] != 0xffffffff); // This is the unused value that represents an empty hash table. You can't use it. Entry *entry = getEntryForKey(key); if (NULL == entry) { return false; } if (entry->key != key) { _ASSERT(entry->key == 0); entry->key = key; usedElementCount++; } entry->value1 = data[0]; entry->value2 = data[1]; return true; }