diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2010-04-21 11:57:31 -0400 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-04-21 12:47:36 -0400 |
commit | 15a2b2e553b078b7e482da822dcb9f8c28c2016c (patch) | |
tree | 5449acb2ef14524a57b4bdd5488f4f3cebc91812 /src | |
parent | 662410d5bdf073e8d8f91dcf4a35de425672d542 (diff) |
IPersistentCollection methods for VecSeq (see #297)
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/gvec.clj | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/clj/clojure/gvec.clj b/src/clj/clojure/gvec.clj index 3f4c5f6e..6c025835 100644 --- a/src/clj/clojure/gvec.clj +++ b/src/clj/clojure/gvec.clj @@ -78,6 +78,30 @@ (more [this] (let [s (.next this)] (or s (clojure.lang.PersistentList/EMPTY)))) + (cons [this o] + (clojure.lang.Cons. o this)) + (count [this] + (loop [i 1 + s (next this)] + (if s + (if (instance? clojure.lang.Counted s) + (+ i (.count s)) + (recur (inc i) (next s))) + i))) + (equiv [this o] + (cond + (identical? this o) true + (or (instance? clojure.lang.Sequential o) (instance? java.util.List o)) + (loop [me this + you (seq o)] + (if (nil? me) + (nil? you) + (and (clojure.lang.Util/equiv (first me) (first you)) + (recur (next me) (next you))))) + :else false)) + (empty [_] + clojure.lang.PersistentList/EMPTY) + clojure.lang.Seqable (seq [this] this) |