From 2b2beb873e0365c8d5add5e888227b9c845a8962 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 6 Mar 2021 15:58:56 +0800 Subject: [PATCH] change dir --- src/experimental/note.md | 2 ++ .../map}/_impl/_hashmap_impl.scad | 4 ++-- .../map}/_impl/_hashmap_put_impl.scad | 6 +++--- src/{collection => util/map}/hashmap.scad | 4 ++-- src/{collection => util/map}/hashmap_del.scad | 6 +++--- src/{collection => util/map}/hashmap_get.scad | 6 +++--- src/{collection => util/map}/hashmap_len.scad | 2 +- src/{collection => util/map}/hashmap_list.scad | 0 src/{collection => util/map}/hashmap_put.scad | 2 +- .../set}/_impl/_hashset_add_impl.scad | 4 ++-- .../set}/_impl/_hashset_impl.scad | 0 src/{collection => util/set}/hashset.scad | 2 +- src/{collection => util/set}/hashset_add.scad | 2 +- src/{collection => util/set}/hashset_del.scad | 6 +++--- src/{collection => util/set}/hashset_has.scad | 4 ++-- src/{collection => util/set}/hashset_len.scad | 2 +- src/{collection => util/set}/hashset_list.scad | 0 test/test_all.scad | 5 ++--- test/{collection => util/map}/test_hashmap.scad | 12 ++++++------ test/{collection => util/set}/test_hashset.scad | 12 ++++++------ 20 files changed, 41 insertions(+), 40 deletions(-) rename src/{collection => util/map}/_impl/_hashmap_impl.scad (56%) rename src/{collection => util/map}/_impl/_hashmap_put_impl.scad (88%) rename src/{collection => util/map}/hashmap.scad (88%) rename src/{collection => util/map}/hashmap_del.scad (81%) rename src/{collection => util/map}/hashmap_get.scad (73%) rename src/{collection => util/map}/hashmap_len.scad (77%) rename src/{collection => util/map}/hashmap_list.scad (100%) rename src/{collection => util/map}/hashmap_put.scad (83%) rename src/{collection => util/set}/_impl/_hashset_add_impl.scad (84%) rename src/{collection => util/set}/_impl/_hashset_impl.scad (100%) rename src/{collection => util/set}/hashset.scad (93%) rename src/{collection => util/set}/hashset_add.scad (82%) rename src/{collection => util/set}/hashset_del.scad (81%) rename src/{collection => util/set}/hashset_has.scad (73%) rename src/{collection => util/set}/hashset_len.scad (77%) rename src/{collection => util/set}/hashset_list.scad (100%) rename test/{collection => util/map}/test_hashmap.scad (82%) rename test/{collection => util/set}/test_hashset.scad (65%) diff --git a/src/experimental/note.md b/src/experimental/note.md index ed2db0b0..35988a5c 100644 --- a/src/experimental/note.md +++ b/src/experimental/note.md @@ -29,6 +29,8 @@ New modules/functions - `util/find_index` - `maze/mz_theta_cells` - `maze/mz_theta_get` +- `util/set/hashset` ... +- `util/map/hashmap` ... - delete `m_cumulate` - delete `trianglate`, use `tri_ear_clipping`? diff --git a/src/collection/_impl/_hashmap_impl.scad b/src/util/map/_impl/_hashmap_impl.scad similarity index 56% rename from src/collection/_impl/_hashmap_impl.scad rename to src/util/map/_impl/_hashmap_impl.scad index b4fc2971..b02e24f0 100644 --- a/src/collection/_impl/_hashmap_impl.scad +++ b/src/util/map/_impl/_hashmap_impl.scad @@ -1,5 +1,5 @@ -use <_hashmap_add_impl.scad>; +use <_hashmap_put_impl.scad>; function _hashmap(kv_lt, leng, buckets, eq, hash, i = 0) = i == leng ? buckets : - _hashmap(kv_lt, leng, _hashmap_add(buckets, kv_lt[i][0], kv_lt[i][1], eq, hash), eq, hash, i + 1); \ No newline at end of file + _hashmap(kv_lt, leng, _hashmap_put(buckets, kv_lt[i][0], kv_lt[i][1], eq, hash), eq, hash, i + 1); \ No newline at end of file diff --git a/src/collection/_impl/_hashmap_put_impl.scad b/src/util/map/_impl/_hashmap_put_impl.scad similarity index 88% rename from src/collection/_impl/_hashmap_put_impl.scad rename to src/util/map/_impl/_hashmap_put_impl.scad index 42e911d5..f58c3a8b 100644 --- a/src/collection/_impl/_hashmap_put_impl.scad +++ b/src/util/map/_impl/_hashmap_put_impl.scad @@ -1,6 +1,6 @@ -use <../../util/slice.scad>; -use <../../util/some.scad>; -use <../../util/find_index.scad>; +use <../../slice.scad>; +use <../../some.scad>; +use <../../find_index.scad>; function _hashmap_put(map, key, value, eq, hash) = let( diff --git a/src/collection/hashmap.scad b/src/util/map/hashmap.scad similarity index 88% rename from src/collection/hashmap.scad rename to src/util/map/hashmap.scad index 79d276c5..927d569d 100644 --- a/src/collection/hashmap.scad +++ b/src/util/map/hashmap.scad @@ -1,6 +1,6 @@ -use <../__comm__/_str_hash.scad>; +use <../../__comm__/_str_hash.scad>; use <_impl/_hashmap_impl.scad>; -use <_impl/_hashmap_add_impl.scad>; +use <_impl/_hashmap_put_impl.scad>; function hashmap(kv_lt, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e), bucket_numbers) = let( diff --git a/src/collection/hashmap_del.scad b/src/util/map/hashmap_del.scad similarity index 81% rename from src/collection/hashmap_del.scad rename to src/util/map/hashmap_del.scad index c42e3b7e..9faa032b 100644 --- a/src/collection/hashmap_del.scad +++ b/src/util/map/hashmap_del.scad @@ -1,6 +1,6 @@ -use <../__comm__/_str_hash.scad>; -use <../util/slice.scad>; -use <../util/find_index.scad>; +use <../../__comm__/_str_hash.scad>; +use <../slice.scad>; +use <../find_index.scad>; function hashmap_del(map, key, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e)) = let( diff --git a/src/collection/hashmap_get.scad b/src/util/map/hashmap_get.scad similarity index 73% rename from src/collection/hashmap_get.scad rename to src/util/map/hashmap_get.scad index 41cb59ba..1078d082 100644 --- a/src/collection/hashmap_get.scad +++ b/src/util/map/hashmap_get.scad @@ -1,6 +1,6 @@ -use <../__comm__/_str_hash.scad>; -use <../util/slice.scad>; -use <../util/find_index.scad>; +use <../../__comm__/_str_hash.scad>; +use <../slice.scad>; +use <../find_index.scad>; function hashmap_get(map, key, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e)) = let( diff --git a/src/collection/hashmap_len.scad b/src/util/map/hashmap_len.scad similarity index 77% rename from src/collection/hashmap_len.scad rename to src/util/map/hashmap_len.scad index 77ce55d3..8b07a3f6 100644 --- a/src/collection/hashmap_len.scad +++ b/src/util/map/hashmap_len.scad @@ -1,4 +1,4 @@ -use <../util/sum.scad>; +use <../sum.scad>; function hashmap_len(map) = sum([ for(bucket = map) diff --git a/src/collection/hashmap_list.scad b/src/util/map/hashmap_list.scad similarity index 100% rename from src/collection/hashmap_list.scad rename to src/util/map/hashmap_list.scad diff --git a/src/collection/hashmap_put.scad b/src/util/map/hashmap_put.scad similarity index 83% rename from src/collection/hashmap_put.scad rename to src/util/map/hashmap_put.scad index e4b55d1f..d7471405 100644 --- a/src/collection/hashmap_put.scad +++ b/src/util/map/hashmap_put.scad @@ -1,4 +1,4 @@ -use <../__comm__/_str_hash.scad>; +use <../../__comm__/_str_hash.scad>; use <_impl/_hashmap_put_impl.scad>; function hashmap_put(map, key, value, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e)) = diff --git a/src/collection/_impl/_hashset_add_impl.scad b/src/util/set/_impl/_hashset_add_impl.scad similarity index 84% rename from src/collection/_impl/_hashset_add_impl.scad rename to src/util/set/_impl/_hashset_add_impl.scad index e95eed92..5803f5ae 100644 --- a/src/collection/_impl/_hashset_add_impl.scad +++ b/src/util/set/_impl/_hashset_add_impl.scad @@ -1,5 +1,5 @@ -use <../../util/slice.scad>; -use <../../util/some.scad>; +use <../../slice.scad>; +use <../../some.scad>; function _hashset_add(set, elem, eq, hash) = let( diff --git a/src/collection/_impl/_hashset_impl.scad b/src/util/set/_impl/_hashset_impl.scad similarity index 100% rename from src/collection/_impl/_hashset_impl.scad rename to src/util/set/_impl/_hashset_impl.scad diff --git a/src/collection/hashset.scad b/src/util/set/hashset.scad similarity index 93% rename from src/collection/hashset.scad rename to src/util/set/hashset.scad index 1696b3db..bef10087 100644 --- a/src/collection/hashset.scad +++ b/src/util/set/hashset.scad @@ -1,4 +1,4 @@ -use <../__comm__/_str_hash.scad>; +use <../../__comm__/_str_hash.scad>; use <_impl/_hashset_impl.scad>; use <_impl/_hashset_add_impl.scad>; diff --git a/src/collection/hashset_add.scad b/src/util/set/hashset_add.scad similarity index 82% rename from src/collection/hashset_add.scad rename to src/util/set/hashset_add.scad index 3418a7ad..b0655b9f 100644 --- a/src/collection/hashset_add.scad +++ b/src/util/set/hashset_add.scad @@ -1,4 +1,4 @@ -use <../__comm__/_str_hash.scad>; +use <../../__comm__/_str_hash.scad>; use <_impl/_hashset_add_impl.scad>; function hashset_add(set, elem, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e)) = diff --git a/src/collection/hashset_del.scad b/src/util/set/hashset_del.scad similarity index 81% rename from src/collection/hashset_del.scad rename to src/util/set/hashset_del.scad index 416ec9c6..3694058c 100644 --- a/src/collection/hashset_del.scad +++ b/src/util/set/hashset_del.scad @@ -1,6 +1,6 @@ -use <../__comm__/_str_hash.scad>; -use <../util/slice.scad>; -use <../util/find_index.scad>; +use <../../__comm__/_str_hash.scad>; +use <../slice.scad>; +use <../find_index.scad>; function hashset_del(set, elem, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e)) = let( diff --git a/src/collection/hashset_has.scad b/src/util/set/hashset_has.scad similarity index 73% rename from src/collection/hashset_has.scad rename to src/util/set/hashset_has.scad index 612dd0ce..efce8c97 100644 --- a/src/collection/hashset_has.scad +++ b/src/util/set/hashset_has.scad @@ -1,5 +1,5 @@ -use <../__comm__/_str_hash.scad>; -use <../util/some.scad>; +use <../../__comm__/_str_hash.scad>; +use <../some.scad>; function hashset_has(set, elem, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(e)) = some(set[hash(elem) % len(set)], function(e) eq(e, elem)); \ No newline at end of file diff --git a/src/collection/hashset_len.scad b/src/util/set/hashset_len.scad similarity index 77% rename from src/collection/hashset_len.scad rename to src/util/set/hashset_len.scad index 3de88d90..c05df352 100644 --- a/src/collection/hashset_len.scad +++ b/src/util/set/hashset_len.scad @@ -1,4 +1,4 @@ -use <../util/sum.scad>; +use <../sum.scad>; function hashset_len(set) = sum([ for(bucket = set) diff --git a/src/collection/hashset_list.scad b/src/util/set/hashset_list.scad similarity index 100% rename from src/collection/hashset_list.scad rename to src/util/set/hashset_list.scad diff --git a/test/test_all.scad b/test/test_all.scad index fabcd48d..3fa6ab0c 100644 --- a/test/test_all.scad +++ b/test/test_all.scad @@ -72,6 +72,8 @@ include ; include ; include ; include ; +include ; +include ; // Voxel include ; @@ -81,6 +83,3 @@ include ; include ; include ; -// Collection -include ; -include ; diff --git a/test/collection/test_hashmap.scad b/test/util/map/test_hashmap.scad similarity index 82% rename from test/collection/test_hashmap.scad rename to test/util/map/test_hashmap.scad index bb50765e..c8079b74 100644 --- a/test/collection/test_hashmap.scad +++ b/test/util/map/test_hashmap.scad @@ -1,9 +1,9 @@ -use ; -use ; -use ; -use ; -use ; -use ; +use ; +use ; +use ; +use ; +use ; +use ; module test_hashmap() { echo("==== test_hashmap ===="); diff --git a/test/collection/test_hashset.scad b/test/util/set/test_hashset.scad similarity index 65% rename from test/collection/test_hashset.scad rename to test/util/set/test_hashset.scad index 9626fdf8..34dc99d6 100644 --- a/test/collection/test_hashset.scad +++ b/test/util/set/test_hashset.scad @@ -1,9 +1,9 @@ -use ; -use ; -use ; -use ; -use ; -use ; +use ; +use ; +use ; +use ; +use ; +use ; module test_hashset() { echo("==== test_hashset ====");