Skip to content

Commit 8387344

Browse files
treemanalexcrichton
authored andcommitted
---
yaml --- r: 132036 b: refs/heads/dist-snap c: 26047f1 h: refs/heads/master v: v3
1 parent 4826ec0 commit 8387344

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 457a3c991d79b971be07fce75f9d0c12848fb37c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: b05f6050b67d1485702ff5ffed666290d4bd1e4d
9+
refs/heads/dist-snap: 26047f15e5f1db33d66979554c29fba3cf4d2c33
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcollections/bitv.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,8 @@ impl BitvSet {
11241124
}
11251125
}
11261126

1127-
/// Iterator over each uint stored in the `self` setminus `other`.
1128-
/// See [difference_with](#method.difference_with) for an efficient in-place version.
1127+
/// Iterator over each uint stored in `self` intersect `other`.
1128+
/// See [intersect_with](#method.intersect_with) for an efficient in-place version.
11291129
///
11301130
/// # Example
11311131
///
@@ -1136,32 +1136,25 @@ impl BitvSet {
11361136
/// let a = BitvSet::from_bitv(from_bytes([0b01101000]));
11371137
/// let b = BitvSet::from_bitv(from_bytes([0b10100000]));
11381138
///
1139-
/// // Print 2, 4 in arbitrary order
1140-
/// for x in a.difference(&b) {
1141-
/// println!("{}", x);
1142-
/// }
1143-
///
1144-
/// // Note that difference is not symmetric,
1145-
/// // and `b - a` means something else.
1146-
/// // This prints 0
1147-
/// for x in b.difference(&a) {
1139+
/// // Print 2
1140+
/// for x in a.intersection(&b) {
11481141
/// println!("{}", x);
11491142
/// }
11501143
/// ```
11511144
#[inline]
1152-
pub fn difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1145+
pub fn intersection<'a>(&'a self, other: &'a BitvSet) -> Take<TwoBitPositions<'a>> {
1146+
let min = cmp::min(self.capacity(), other.capacity());
11531147
TwoBitPositions {
11541148
set: self,
11551149
other: other,
1156-
merge: |w1, w2| w1 & !w2,
1150+
merge: |w1, w2| w1 & w2,
11571151
current_word: 0,
11581152
next_idx: 0
1159-
}
1153+
}.take(min)
11601154
}
11611155

1162-
/// Iterator over each uint stored in the symmetric difference of `self` and `other`.
1163-
/// See [symmetric_difference_with](#method.symmetric_difference_with) for
1164-
/// an efficient in-place version.
1156+
/// Iterator over each uint stored in the `self` setminus `other`.
1157+
/// See [difference_with](#method.difference_with) for an efficient in-place version.
11651158
///
11661159
/// # Example
11671160
///
@@ -1172,24 +1165,32 @@ impl BitvSet {
11721165
/// let a = BitvSet::from_bitv(from_bytes([0b01101000]));
11731166
/// let b = BitvSet::from_bitv(from_bytes([0b10100000]));
11741167
///
1175-
/// // Print 0, 1, 4 in arbitrary order
1176-
/// for x in a.symmetric_difference(&b) {
1168+
/// // Print 2, 4 in arbitrary order
1169+
/// for x in a.difference(&b) {
1170+
/// println!("{}", x);
1171+
/// }
1172+
///
1173+
/// // Note that difference is not symmetric,
1174+
/// // and `b - a` means something else.
1175+
/// // This prints 0
1176+
/// for x in b.difference(&a) {
11771177
/// println!("{}", x);
11781178
/// }
11791179
/// ```
11801180
#[inline]
1181-
pub fn symmetric_difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1181+
pub fn difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
11821182
TwoBitPositions {
11831183
set: self,
11841184
other: other,
1185-
merge: |w1, w2| w1 ^ w2,
1185+
merge: |w1, w2| w1 & !w2,
11861186
current_word: 0,
11871187
next_idx: 0
11881188
}
11891189
}
11901190

1191-
/// Iterator over each uint stored in `self` intersect `other`.
1192-
/// See [intersect_with](#method.intersect_with) for an efficient in-place version.
1191+
/// Iterator over each uint stored in the symmetric difference of `self` and `other`.
1192+
/// See [symmetric_difference_with](#method.symmetric_difference_with) for
1193+
/// an efficient in-place version.
11931194
///
11941195
/// # Example
11951196
///
@@ -1200,21 +1201,20 @@ impl BitvSet {
12001201
/// let a = BitvSet::from_bitv(from_bytes([0b01101000]));
12011202
/// let b = BitvSet::from_bitv(from_bytes([0b10100000]));
12021203
///
1203-
/// // Print 2
1204-
/// for x in a.intersection(&b) {
1204+
/// // Print 0, 1, 4 in arbitrary order
1205+
/// for x in a.symmetric_difference(&b) {
12051206
/// println!("{}", x);
12061207
/// }
12071208
/// ```
12081209
#[inline]
1209-
pub fn intersection<'a>(&'a self, other: &'a BitvSet) -> Take<TwoBitPositions<'a>> {
1210-
let min = cmp::min(self.capacity(), other.capacity());
1210+
pub fn symmetric_difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
12111211
TwoBitPositions {
12121212
set: self,
12131213
other: other,
1214-
merge: |w1, w2| w1 & w2,
1214+
merge: |w1, w2| w1 ^ w2,
12151215
current_word: 0,
12161216
next_idx: 0
1217-
}.take(min)
1217+
}
12181218
}
12191219

12201220
/// Union in-place with the specified other bit vector.

0 commit comments

Comments
 (0)