Cell* srcCells = m_cells;
ureg srcSize = m_sizeMask + 1;
m_cells = createTable(desiredSize);
Cell* srcCells = m_cells;
ureg srcSize = m_sizeMask + 1;
m_cells = createTable(desiredSize);
- SingleMap_Linear(size_t initialSize = 8) : m_cells(createTable(initialSize)), m_sizeMask(initialSize - 1), m_population(0) {
- TURF_ASSERT(turf::util::isPowerOf2(initialSize));
+ SingleMap_Linear(ureg initialSize = 8) : m_cells(createTable(initialSize)), m_sizeMask(initialSize - 1), m_population(0) {
Hash hash = KeyTraits::hash(key);
TURF_ASSERT(hash != KeyTraits::NullHash);
for (ureg idx = hash;; idx++) {
idx &= map.m_sizeMask;
m_cell = map.m_cells + idx;
if (m_cell->hash == hash)
Hash hash = KeyTraits::hash(key);
TURF_ASSERT(hash != KeyTraits::NullHash);
for (ureg idx = hash;; idx++) {
idx &= map.m_sizeMask;
m_cell = map.m_cells + idx;
if (m_cell->hash == hash)
- continue; // Slot is taken by another key. Try next slot.
- m_cell = NULL; // Insert not allowed & key not found.
+ continue; // Slot is taken by another key. Try next slot.
+ m_cell = NULL; // Insert not allowed & key not found.
// Insert is allowed. Reserve this cell.
if (isOverpopulated(map.m_population, map.m_sizeMask)) {
map.migrateToNewTable((map.m_sizeMask + 1) * 2);
// Insert is allowed. Reserve this cell.
if (isOverpopulated(map.m_population, map.m_sizeMask)) {
map.migrateToNewTable((map.m_sizeMask + 1) * 2);
Value oldValue = m_cell->value;
// Remove this cell by shuffling neighboring cells so there are no gaps in anyone's probe chain
Value oldValue = m_cell->value;
// Remove this cell by shuffling neighboring cells so there are no gaps in anyone's probe chain
for (ureg neighborIdx = cellIdx + 1;; neighborIdx++) {
neighborIdx &= m_map.m_sizeMask;
Cell* neighbor = m_map.m_cells + neighborIdx;
if (neighbor->hash == KeyTraits::NullHash) {
// Go ahead and clear this cell. It won't break anyone else's probe chain.
m_cell->hash = KeyTraits::NullHash;
for (ureg neighborIdx = cellIdx + 1;; neighborIdx++) {
neighborIdx &= m_map.m_sizeMask;
Cell* neighbor = m_map.m_cells + neighborIdx;
if (neighbor->hash == KeyTraits::NullHash) {
// Go ahead and clear this cell. It won't break anyone else's probe chain.
m_cell->hash = KeyTraits::NullHash;
- Iterator insertOrFindKey(const Key& key) {
- return Iterator(*this, key);
+ Mutator insertOrFindKey(const Key& key) {
+ return Mutator(*this, key);
- Value insert(const Key& key, Value desired) {
- Iterator iter(*this, key);
+ Value set(const Key& key, Value desired) {
+ Mutator iter(*this, key);