Skip to content

Commit

Permalink
Refactor IntSets to use BitVectors
Browse files Browse the repository at this point in the history
* Use BitVectors instead of a mismash of bitvector.c and ad-hoc Julia code.
* Invert the complement IntSet semantics.  Instead of filling ones outside the range of the IntSet, simply reverse what a set bit means.
* For mathematical functions (intersect, union, etc.), use BitVector functions to work 64 bits at a time instead of working bit-by-bit.
* Increase test-coverage to 100%
  • Loading branch information
mbauman committed Mar 10, 2015
1 parent aecda29 commit 782f34c
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 305 deletions.
13 changes: 4 additions & 9 deletions base/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,10 @@ end

const hashis_seed = UInt === UInt64 ? 0x88989f1fc7dea67d : 0xc7dea67d
function hash(s::IntSet, h::UInt)
h += hashis_seed
h += hash(s.fill1s)
filln = s.fill1s ? ~zero(eltype(s.bits)) : zero(eltype(s.bits))
for x in s.bits
if x != filln
h = hash(x, h)
end
end
return h
# Only hash the bits array up to the last-set bit to prevent extra empty
# bits from changing the hash result
l = findprev(s.bits, length(s.bits))
hash(unsafe_getindex(s.bits, 1:l), h) $ hash(s.inverse) $ hashis_seed
end

# hashing ranges by component at worst leads to collisions for very similar ranges
Expand Down
Loading

0 comments on commit 782f34c

Please sign in to comment.