summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2010-04-28 13:02:17 -0400
committerRich Hickey <richhickey@gmail.com>2010-04-28 13:02:17 -0400
commitfab49c61d0b383d00270684a40bdf19bb2313ca6 (patch)
tree47975e7102c8933c2b0ddf62bc9f92055a50167e /src
parenta55df92faa0c51c634d93a8d991ccfd2638b108b (diff)
parent57b320020e9387d1a2a6b7ff71ce2b5d6959fc10 (diff)
Merge branch 'master' into seqfnsseqfns
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/gvec.clj26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/clj/clojure/gvec.clj b/src/clj/clojure/gvec.clj
index f9e65ba5..c8a70e47 100644
--- a/src/clj/clojure/gvec.clj
+++ b/src/clj/clojure/gvec.clj
@@ -245,6 +245,14 @@
(if (clojure.lang.Util/isInteger k)
(.assocN this k v)
(throw (IllegalArgumentException. "Key must be integer"))))
+ (containsKey [this k]
+ (and (clojure.lang.Util/isInteger k)
+ (<= 0 (int k))
+ (< (int k) cnt)))
+ (entryAt [this k]
+ (if (.containsKey this k)
+ (clojure.lang.MapEntry. k (.nth this (int k)))
+ nil))
clojure.lang.ILookup
(valAt [this k not-found]
@@ -335,6 +343,24 @@
(aset arr subidx (.doAssoc this (- level (int 5)) (aget arr subidx) i val))
(VecNode. (.edit node) arr))))
+ java.lang.Comparable
+ (compareTo [this o]
+ (if (identical? this o)
+ 0
+ (let [#^clojure.lang.IPersistentVector v (cast clojure.lang.IPersistentVector o)
+ vcnt (.count v)]
+ (cond
+ (< cnt vcnt) -1
+ (> cnt vcnt) 1
+ :else
+ (loop [i (int 0)]
+ (if (= i cnt)
+ 0
+ (let [comp (clojure.lang.Util/compare (.nth this i) (.nth v i))]
+ (if (= 0 comp)
+ (recur (inc i))
+ comp))))))))
+
java.lang.Iterable
(iterator [this]
(let [i (java.util.concurrent.atomic.AtomicInteger. 0)]