summaryrefslogtreecommitdiff
path: root/src/cli/runtime/PersistentArray.cs
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-06-09 13:24:23 +0000
committerRich Hickey <richhickey@gmail.com>2006-06-09 13:24:23 +0000
commit7b244d43c7c52dfab7fef2d77073705aeac604cc (patch)
tree9eb3319a3d18a8c3555b7caa76ebcf0d1d41e288 /src/cli/runtime/PersistentArray.cs
parente4e5b0612f3acbcd223e8a7c27510bf9a2dde856 (diff)
made ISequential
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;