aboutsummaryrefslogtreecommitdiff
path: root/clojurescript/hashtopology.js
diff options
context:
space:
mode:
Diffstat (limited to 'clojurescript/hashtopology.js')
-rw-r--r--clojurescript/hashtopology.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/clojurescript/hashtopology.js b/clojurescript/hashtopology.js
new file mode 100644
index 00000000..d9633a94
--- /dev/null
+++ b/clojurescript/hashtopology.js
@@ -0,0 +1,28 @@
+// display topology of hashmaps, for debugging
+function maptop(x,d) {
+ d = d || "";
+ var d2 = d + " ";
+ var c = x.constructor.classname;
+ print(d+c);
+ switch(c) {
+ case "PersistentHashMap": maptop(x._root,d2); break;
+ case "BitmapIndexedNode":
+ case "FullNode":
+ for( var i = 0; i < x.nodes.length; ++i ) {
+ maptop(x.nodes[i],d2);
+ }
+ break;
+ case "HashCollisionNode":
+ for( var i = 0; i < x.leaves.length; ++i ) {
+ maptop(x.leaves[i],d2);
+ }
+ break;
+ case "LeafNode": print( d2 + x.key() + " : " + x.val() ); break;
+ }
+}
+
+y = clojure.lang.PersistentHashMap.EMPTY;
+for( var i = 0; i < 10; ++i ) {
+ y = y.assoc( "a" + String.fromCharCode( 48 + i ), i );
+ maptop( y );
+}