VM: Remove unused (and incomplete) HashMap::Remove() function

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2542103002 .
This commit is contained in:
Martin Kustermann 2016-12-01 13:51:49 +01:00
parent ff8951a515
commit 37dfdbdc97
3 changed files with 0 additions and 77 deletions

View file

@ -180,47 +180,4 @@ UNIT_TEST_CASE(HashMap_Basic) {
TestSet(CollisionHash4, 50);
}
UNIT_TEST_CASE(HashMap_RemoveDuringIteration) {
class Utils {
public:
static bool MatchFun(void* key1, void* key2) { return key1 == key2; }
static void* Key(intptr_t i) { return reinterpret_cast<void*>(i); }
static void* Value(intptr_t i) { return reinterpret_cast<void*>(i); }
static uint32_t HashCode(intptr_t key) { return 1; }
};
HashMap map(Utils::MatchFun, 8);
// Add 6 (1, 1), ..., (6, 60) entries to the map all with a hashcode of 1
// (i.e. have all keys have collinding hashcode).
//
// This causes the probing position in the hashmap to be 1 and open-addressing
// with linear probing will fill in the slots towards the right
// (i.e. from 1..6).
for (intptr_t i = 1; i <= 6 /* avoid rehash at 7 */; i++) {
HashMap::Entry* entry = map.Lookup(Utils::Key(i), Utils::HashCode(i), true);
entry->value = Utils::Value(10 * i);
}
// Now we iterate over all elements and delete the current element. Since all
// our entries have a colliding hashcode of 1, each deletion will cause all
// following elements to be left-rotated by 1.
intptr_t i = 0;
HashMap::Entry* current = map.Start();
while (current != NULL) {
i++;
EXPECT_EQ(Utils::Key(i), current->key);
EXPECT_EQ(Utils::Value(10 * i), current->value);
// Every 2nd element we keep to hit the left-rotation case only sometimes.
if (i % 2 == 0) {
current = map.Remove(current);
} else {
current = map.Next(current);
}
}
EXPECT_EQ(6, i);
}
} // namespace dart

View file

@ -110,23 +110,6 @@ void HashMap::Remove(void* key, uint32_t hash) {
}
HashMap::Entry* HashMap::Remove(Entry* entry) {
Remove(entry->key, entry->hash);
// A key can only exist once in the map and we just removed `key`. This means
// that either a left-rotation has happened (in which case `entry` points
// already to the next element (in terms of iteration order)) or alternatively
// we can use the normal `Next()` call to move in iteration order.
if (entry->key != NULL) {
// A left-rotation happened. `entry` points already to the next element in
// iteration order.
return entry;
} else {
return Next(entry);
}
}
void HashMap::Clear(ClearFun clear) {
// Mark all entries as empty.
const Entry* end = map_end();

View file

@ -66,23 +66,6 @@ class HashMap {
// otherwise the iteration might step over elements!
void Remove(void* key, uint32_t hash);
// Removes the entry and returns the next entry (in iteration order) after
// this one.
//
// Usage instructions for removing elements during iteration:
//
// HashMap::Entry* current = map.Start();
// while (current != NULL) {
// ...
// if (condition) {
// current = map.Remove(current);
// } else {
// current = map.Next(current);
// }
// }
//
Entry* Remove(Entry* entry);
// Empties the hash map (occupancy() == 0), and calls the function 'clear' on
// each of the values if given.
void Clear(ClearFun clear = NULL);