summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Solano Gómez <clojure@sattvik.com>2010-04-25 14:50:15 -0500
committerStuart Halloway <stu@thinkrelevance.com>2010-04-27 15:39:18 -0400
commitdc9429f5cb6a0d881bc0e4ee1ae030543bb72655 (patch)
tree570a1eb18a7fdc33a521c91a9a16567ce15d9fa4 /src
parentf6c74643606461e119998421e39c1972e255d128 (diff)
Add containsKey and entryAt support to Vec, plus tests. Fixes #314.
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/gvec.clj8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/clj/clojure/gvec.clj b/src/clj/clojure/gvec.clj
index 7da8e49e..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]