summaryrefslogtreecommitdiff
path: root/src/cli/runtime/ArraySeq.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/runtime/ArraySeq.cs')
-rw-r--r--src/cli/runtime/ArraySeq.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/cli/runtime/ArraySeq.cs b/src/cli/runtime/ArraySeq.cs
new file mode 100644
index 00000000..c0e450b4
--- /dev/null
+++ b/src/cli/runtime/ArraySeq.cs
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ **/
+
+/* rich Jun 19, 2006 */
+
+using System;
+
+namespace clojure.lang
+{
+
+public class ArraySeq : IndexedSeq{
+readonly Object[] array;
+readonly int i;
+
+static public ArraySeq create(Object[] array){
+ if(array.Length == 0)
+ return null;
+ return new ArraySeq(array, 0);
+}
+
+ArraySeq(Object[] array, int i){
+ this.array = array;
+ this.i = i;
+}
+
+public Object first() {
+ return array[i];
+}
+
+public ISeq rest() {
+ if(i+1 < array.Length)
+ return new ArraySeq(array, i + 1);
+ return null;
+}
+
+public int index(){
+ return i;
+}
+}
+
+}