1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-12 17:54:18 +02:00
This commit is contained in:
Justin Lin
2022-03-04 13:40:29 +08:00
parent dff91873b3
commit 18ecbcee93
6 changed files with 9 additions and 24 deletions

View File

@@ -19,11 +19,7 @@ function dedup(lt, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(
b_numbers = is_undef(number_of_buckets) ? ceil(sqrt(leng_lt)) : number_of_buckets,
buckets = [for(i = [0:b_numbers - 1]) []],
deduped = _dedup(lt, leng_lt, buckets, eq, hash, b_numbers),
i_elem_lt = [
for(bucket = deduped)
for(i_elem = bucket)
i_elem
],
i_elem_lt = [for(bucket = deduped) each bucket],
sorted = sort(i_elem_lt, by = function(e1, e2) e1[0] - e2[0])
)
[for(i_elem = sorted) i_elem[1]];

View File

@@ -2,5 +2,8 @@ use <_hashmap_put_impl.scad>;
function _hashmap(kv_lt, leng, buckets, b_numbers, eq, hash, i = 0) =
i == leng ? buckets :
let(n_buckets = _hashmap_put(buckets, b_numbers, kv_lt[i][0], kv_lt[i][1], eq, hash))
let(
kv_lt_i = kv_lt[i],
n_buckets = _hashmap_put(buckets, b_numbers, kv_lt_i[0], kv_lt_i[1], eq, hash)
)
_hashmap(kv_lt, leng, n_buckets, b_numbers, eq, hash, i + 1);

View File

@@ -8,8 +8,4 @@
*
**/
function hashmap_entries(map) = [
for(bucket = map)
for(kv = bucket)
kv
];
function hashmap_entries(map) = [for(bucket = map) each bucket];

View File

@@ -10,7 +10,4 @@
use <../sum.scad>;
function hashmap_len(map) = sum([
for(bucket = map)
len(bucket)
]);
function hashmap_len(map) = sum([for(bucket = map) len(bucket)]);

View File

@@ -8,8 +8,4 @@
*
**/
function hashset_elems(set) = [
for(bucket = set)
for(elem = bucket)
elem
];
function hashset_elems(set) = [for(bucket = set) each bucket];

View File

@@ -10,7 +10,4 @@
use <../sum.scad>;
function hashset_len(set) = sum([
for(bucket = set)
len(bucket)
]);
function hashset_len(set) = sum([for(bucket = set) len(bucket)]);