1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-04-20 06:02:05 +02:00
This commit is contained in:
Justin Lin 2021-03-05 07:54:48 +08:00
parent f82cd92d9e
commit 6516f7206c
2 changed files with 19 additions and 1 deletions

View File

@ -44,7 +44,7 @@ function hashset_del(set, elem, hash = df_hash, eq = df_eq) =
leng = len(bucket)
)
leng == 0 ? set :
let(i = _find(bucket, elem, eq, leng), _ = echo(i))
let(i = _find(bucket, elem, eq, leng))
i == -1 ? set :
concat(
slice(set, 0, bidx),

View File

@ -0,0 +1,18 @@
use <unittest.scad>;
use <collection/hashset.scad>;
module test_hashset() {
echo("==== test_hashset ====");
s = hashset([1, 2, 3, 4, 5, 2, 3, 5]);
assert(hashset_list(s) == [1, 2, 3, 4, 5]);
s2 = hashset_add(s, 9);
assert(hashset_list(s2) == [1, 2, 3, 4, 5, 9]);
assert(!hashset_has(s2, 13));
assert(hashset_list(hashset_del(s2, 2)) == [1, 3, 4, 5, 9]);
}
test_hashset();