Skip to content

Commit

Permalink
Fixing bitvset is_disjoint, fixes #16587
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Aug 18, 2014
1 parent 40c4516 commit dcccf82
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/libcollections/bitv.rs
Expand Up @@ -1522,7 +1522,7 @@ impl Set<uint> for BitvSet {

#[inline]
fn is_disjoint(&self, other: &BitvSet) -> bool {
self.intersection(other).count() > 0
self.intersection(other).next().is_none()
}

#[inline]
Expand Down Expand Up @@ -2264,6 +2264,24 @@ mod tests {
assert!(set1.is_subset(&set2)); // { 2 } { 2, 4 }
}

#[test]
fn test_bitv_set_is_disjoint() {
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
let b = BitvSet::from_bitv(from_bytes([0b01000000]));
let c = BitvSet::new();
let d = BitvSet::from_bitv(from_bytes([0b00110000]));

assert!(!a.is_disjoint(&d));
assert!(!d.is_disjoint(&a));

assert!(a.is_disjoint(&b))
assert!(a.is_disjoint(&c))
assert!(b.is_disjoint(&a))
assert!(b.is_disjoint(&c))
assert!(c.is_disjoint(&a))
assert!(c.is_disjoint(&b))
}

#[test]
fn test_bitv_set_intersect_with() {
// Explicitly 0'ed bits
Expand Down

5 comments on commit dcccf82

@bors
Copy link
Contributor

@bors bors commented on dcccf82 Aug 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Gankra@dcccf82

@bors
Copy link
Contributor

@bors bors commented on dcccf82 Aug 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Gankro/rust/bitv = dcccf82 into auto

@bors
Copy link
Contributor

@bors bors commented on dcccf82 Aug 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gankro/rust/bitv = dcccf82 merged ok, testing candidate = 9af4e32

@bors
Copy link
Contributor

@bors bors commented on dcccf82 Aug 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9af4e32

Please sign in to comment.