summaryrefslogtreecommitdiff
path: root/src/cli/runtime/PersistentArray.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/runtime/PersistentArray.cs')
-rw-r--r--src/cli/runtime/PersistentArray.cs31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/cli/runtime/PersistentArray.cs b/src/cli/runtime/PersistentArray.cs
index f9684901..71002269 100644
--- a/src/cli/runtime/PersistentArray.cs
+++ b/src/cli/runtime/PersistentArray.cs
@@ -44,7 +44,7 @@ namespace org.clojure.runtime
* Java implementation is lock-free
*/
-public class PersistentArray : IEnumerable{
+public class PersistentArray : IEnumerable, ISequential{
#region IEnumerable Members
@@ -54,7 +54,14 @@ public class PersistentArray : IEnumerable{
}
#endregion
-
+
+ public ISeq seq()
+ {
+ if (length() > 0)
+ return new Seq(this, 0);
+ return null;
+ }
+
internal class Master{
internal readonly Entry[] array;
internal readonly Object defaultVal;
@@ -111,6 +118,26 @@ internal class EntryLink : Entry
}
}
+internal class Seq : ISeq{
+ PersistentArray p;
+ int i;
+
+ internal Seq(PersistentArray p, int i){
+ this.p = p;
+ this.i = i;
+ }
+
+ public Object first() {
+ return p.get(i);
+ }
+
+ public ISeq rest() {
+ if(i+1 < p.length())
+ return new Seq(p, i + 1);
+ return null;
+ }
+}
+
internal class ValIter : IEnumerator
{
internal PersistentArray p;