summaryrefslogtreecommitdiff
path: root/src/cli/runtime/PersistentArray.cs
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-08-07 17:13:55 +0000
committerRich Hickey <richhickey@gmail.com>2006-08-07 17:13:55 +0000
commit108db3bc660f25860a201fbd2769ef2640f300bf (patch)
tree99a4ad8ceb4680d242c38fbf724ef6194a26afbb /src/cli/runtime/PersistentArray.cs
parent0165bc3a0df548701007dcff28dd4b5781cc9e31 (diff)
added PersistentQueue
Diffstat (limited to 'src/cli/runtime/PersistentArray.cs')
-rw-r--r--src/cli/runtime/PersistentArray.cs40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/cli/runtime/PersistentArray.cs b/src/cli/runtime/PersistentArray.cs
index 3c766661..ced36518 100644
--- a/src/cli/runtime/PersistentArray.cs
+++ b/src/cli/runtime/PersistentArray.cs
@@ -63,7 +63,12 @@ namespace clojure.lang
return null;
}
-
+ public ISeq rseq()
+ {
+ if (count() > 0)
+ return new RSeq(this, count() - 1);
+ return null;
+ }
internal class Master{
internal readonly Entry[] array;
@@ -154,6 +159,10 @@ internal class Seq : ASeq, IndexedSeq{
return null;
}
+ public override int count() {
+ return p.count() - i;
+ }
+
#region IndexedSeq Members
public int index()
@@ -164,6 +173,33 @@ public int index()
#endregion
}
+class RSeq : ASeq, IndexedSeq{
+ readonly PersistentArray p;
+ readonly int i;
+
+ internal RSeq(PersistentArray p, int i){
+ this.p = p;
+ this.i = i;
+ }
+
+ public override Object first() {
+ return p.nth(i);
+ }
+
+ public override ISeq rest() {
+ if(i > 0)
+ return new RSeq(p, i - 1);
+ return null;
+ }
+
+ public int index() {
+ return i;
+ }
+
+ public override int count() {
+ return i + 1;
+ }
+}
internal class ValIter : IEnumerator
{
internal PersistentArray p;
@@ -491,7 +527,7 @@ internal virtual PersistentArray create(int size, Object defaultVal, float loadF
}
-//*
+/*
[STAThread]
static public void Main(String[] args){
if(args.Length != 3)