Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Enhance hash function to be compatible with Clojure 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jafingerhut committed Feb 16, 2014
1 parent 93ec698 commit 515c860
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion project.clj
Expand Up @@ -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"])
11 changes: 11 additions & 0 deletions src/immutable_bitset.clj
Expand Up @@ -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
Expand All @@ -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)))
Expand Down

0 comments on commit 515c860

Please sign in to comment.