1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-23 14:54:12 +02:00
This commit is contained in:
Justin Lin
2021-03-06 22:33:27 +08:00
parent 24a08960c7
commit 139df57f1a
2 changed files with 7 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
function hashmap_list(map) = [ function hashmap_entries(map) = [
for(bucket = map) for(bucket = map)
for(kv = bucket) for(kv = bucket)
kv kv

View File

@@ -1,5 +1,5 @@
use <util/map/hashmap.scad>; use <util/map/hashmap.scad>;
use <util/map/hashmap_list.scad>; use <util/map/hashmap_entries.scad>;
use <util/map/hashmap_put.scad>; use <util/map/hashmap_put.scad>;
use <util/map/hashmap_len.scad>; use <util/map/hashmap_len.scad>;
use <util/map/hashmap_del.scad>; use <util/map/hashmap_del.scad>;
@@ -17,17 +17,17 @@ module test_hashmap() {
assert(hashmap_len(s) == 4); assert(hashmap_len(s) == 4);
assert(hashmap_list(s) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 2]]); assert(hashmap_entries(s) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 2]]);
s2 = hashmap_put(s, "k1357", 100); s2 = hashmap_put(s, "k1357", 100);
assert(hashmap_list(s2) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 2], ["k1357", 100]]); assert(hashmap_entries(s2) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 2], ["k1357", 100]]);
s3 = hashmap_put(s2, "k5678", 200); s3 = hashmap_put(s2, "k5678", 200);
assert(hashmap_list(s3) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]); assert(hashmap_entries(s3) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
s4 = hashmap_del(s3, "k4444"); s4 = hashmap_del(s3, "k4444");
assert(hashmap_list(s4) == [["k9876", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]); assert(hashmap_entries(s4) == [["k9876", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
assert(hashmap_list(hashmap_del(s4, "k4444")) == [["k9876", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]); assert(hashmap_entries(hashmap_del(s4, "k4444")) == [["k9876", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
assert(hashmap_get(s4, "k1234") == 1); assert(hashmap_get(s4, "k1234") == 1);
assert(hashmap_get(s4, "k0000") == undef); assert(hashmap_get(s4, "k0000") == undef);