updated OAHashMap to use robinhood hashing

This commit is contained in:
karroffel
2018-05-03 14:40:55 +02:00
parent 2e474f42b8
commit bf24d570bb
5 changed files with 196 additions and 463 deletions
+189 -456
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -49,7 +49,7 @@ MainLoop *test() {
map.set(42, 11880);
int value;
map.lookup(42, &value);
map.lookup(42, value);
OS::get_singleton()->print("capacity %d\n", map.get_capacity());
OS::get_singleton()->print("elements %d\n", map.get_num_elements());
@@ -72,7 +72,7 @@ MainLoop *test() {
uint32_t num_elems = 0;
for (int i = 0; i < 500; i++) {
int tmp;
if (map.lookup(i, &tmp))
if (map.lookup(i, tmp) && tmp == i * 2)
num_elems++;
}
@@ -88,7 +88,7 @@ MainLoop *test() {
map.set("Godot rocks", 42);
for (OAHashMap<String, int>::Iterator it = map.iter(); it.valid; it = map.next_iter(it)) {
OS::get_singleton()->print("map[\"%s\"] = %d\n", it.key->utf8().get_data(), *it.data);
OS::get_singleton()->print("map[\"%s\"] = %d\n", it.key->utf8().get_data(), *it.value);
}
}
+1 -1
View File
@@ -1255,7 +1255,7 @@ void CSGBrushOperation::MeshMerge::add_face(const Vector3 &p_a, const Vector3 &p
vk.z = int((double(src_points[i].z) + double(vertex_snap) * 0.31234) / double(vertex_snap));
int res;
if (snap_cache.lookup(vk, &res)) {
if (snap_cache.lookup(vk, res)) {
indices[i] = res;
} else {
indices[i] = points.size();
+1 -1
View File
@@ -108,7 +108,7 @@ struct CSGBrushOperation {
}
};
OAHashMap<VertexKey, int, 64, VertexKeyHash> snap_cache;
OAHashMap<VertexKey, int, VertexKeyHash> snap_cache;
Vector<Vector3> points;
+2 -2
View File
@@ -157,7 +157,7 @@ void CSGShape::_update_shape() {
for (int j = 0; j < 3; j++) {
Vector3 v = n->faces[i].vertices[j];
Vector3 add;
if (vec_map.lookup(v, &add)) {
if (vec_map.lookup(v, add)) {
add += p.normal;
} else {
add = p.normal;
@@ -233,7 +233,7 @@ void CSGShape::_update_shape() {
Vector3 normal = p.normal;
if (n->faces[i].smooth && vec_map.lookup(v, &normal)) {
if (n->faces[i].smooth && vec_map.lookup(v, normal)) {
normal.normalize();
}