Skip to content

Commit 3046df0

Browse files
treemanalexcrichton
authored andcommitted
---
yaml --- r: 124824 b: refs/heads/auto c: 26047f1 h: refs/heads/master v: v3
1 parent 1edbf8e commit 3046df0

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
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: b05f6050b67d1485702ff5ffed666290d4bd1e4d
16+
refs/heads/auto: 26047f15e5f1db33d66979554c29fba3cf4d2c33
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)