Permalink
Browse files

Enhance hash function to be compatible with Clojure 1.6

  • Loading branch information...
1 parent 93ec698 commit 515c8607f6472bdcad3443600761b7229ded1f4d @jafingerhut jafingerhut committed Feb 16, 2014
Showing with 13 additions and 1 deletion.
  1. +2 −1 project.clj
  2. +11 −0 src/immutable_bitset.clj
View
@@ -7,7 +7,8 @@
:profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]
[criterium "0.4.1"]
[reiddraper/simple-check "0.5.1"]
- [collection-check "0.1.1-SNAPSHOT"]]}}
+ [collection-check "0.1.1-SNAPSHOT"]]}
+ :1.6 {:dependencies [[org.clojure/clojure "1.6.0-beta1"]]}}
:test-selectors {:default (complement :benchmark)
:benchmark :benchmark}
:jvm-opts ^:replace ["-server"])
View
@@ -52,6 +52,11 @@
cnt#
(p/inc cnt#))))
+(defmacro compile-if [test then else]
+ (if (eval test)
+ then
+ else))
+
(deftype PersistentBitSet
[^byte log2-chunk-size
^int generation
@@ -68,6 +73,12 @@
(reduce #(p/+ (long %1) (long %2))))))
(equals [this x] (.equiv this x))
+ clojure.lang.IHashEq
+ (hasheq [this]
+ (compile-if (resolve 'clojure.core/hash-unordered-coll)
+ (hash-unordered-coll this)
+ (.hashCode this)))
+
java.util.Set
(size [this] (count this))
(isEmpty [this] (zero? (count this)))

0 comments on commit 515c860

Please sign in to comment.