summaryrefslogtreecommitdiff
path: root/src/cli/runtime/PersistentHashtableMap.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/runtime/PersistentHashtableMap.cs')
-rw-r--r--src/cli/runtime/PersistentHashtableMap.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/cli/runtime/PersistentHashtableMap.cs b/src/cli/runtime/PersistentHashtableMap.cs
index e00cd565..66732b72 100644
--- a/src/cli/runtime/PersistentHashtableMap.cs
+++ b/src/cli/runtime/PersistentHashtableMap.cs
@@ -152,6 +152,46 @@ public virtual IEnumerator GetEnumerator() {
return new Iter(array);
}
+public ISeq seq() {
+ return Seq.create(array);
+}
+
+class Seq : ISeq{
+ PersistentArray buckets;
+ int b;
+ ISeq e;
+
+
+ static public Seq create(PersistentArray buckets) {
+ return next(buckets, -1, null);
+ }
+
+ static Seq next(PersistentArray buckets, int b, ISeq e) {
+ if(e != null && e.rest() != null)
+ return new Seq(buckets,b,e.rest());
+ for(b = b+1;b<buckets.length();b++)
+ {
+ ISequential a = (ISequential) buckets.get(b);
+ if(a != null && a.seq() != null)
+ return new Seq(buckets,b,a.seq());
+ }
+ return null;
+ }
+
+ Seq(PersistentArray buckets, int b, ISeq e) {
+ this.buckets = buckets;
+ this.b = b;
+ this.e = e;
+ }
+
+ public Object first() {
+ return e.first();
+ }
+
+ public ISeq rest() {
+ return next(buckets,b,e);
+ }
+}
internal class Iter : IEnumerator{
PersistentArray buckets;