@@ -1124,8 +1124,8 @@ impl BitvSet {
1124
1124
}
1125
1125
}
1126
1126
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.
1129
1129
///
1130
1130
/// # Example
1131
1131
///
@@ -1136,32 +1136,25 @@ impl BitvSet {
1136
1136
/// let a = BitvSet::from_bitv(from_bytes([0b01101000]));
1137
1137
/// let b = BitvSet::from_bitv(from_bytes([0b10100000]));
1138
1138
///
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) {
1148
1141
/// println!("{}", x);
1149
1142
/// }
1150
1143
/// ```
1151
1144
#[ 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 ( ) ) ;
1153
1147
TwoBitPositions {
1154
1148
set : self ,
1155
1149
other : other,
1156
- merge : |w1, w2| w1 & ! w2,
1150
+ merge : |w1, w2| w1 & w2,
1157
1151
current_word : 0 ,
1158
1152
next_idx : 0
1159
- }
1153
+ } . take ( min )
1160
1154
}
1161
1155
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.
1165
1158
///
1166
1159
/// # Example
1167
1160
///
@@ -1172,24 +1165,32 @@ impl BitvSet {
1172
1165
/// let a = BitvSet::from_bitv(from_bytes([0b01101000]));
1173
1166
/// let b = BitvSet::from_bitv(from_bytes([0b10100000]));
1174
1167
///
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) {
1177
1177
/// println!("{}", x);
1178
1178
/// }
1179
1179
/// ```
1180
1180
#[ 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 > {
1182
1182
TwoBitPositions {
1183
1183
set : self ,
1184
1184
other : other,
1185
- merge : |w1, w2| w1 ^ w2,
1185
+ merge : |w1, w2| w1 & ! w2,
1186
1186
current_word : 0 ,
1187
1187
next_idx : 0
1188
1188
}
1189
1189
}
1190
1190
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.
1193
1194
///
1194
1195
/// # Example
1195
1196
///
@@ -1200,21 +1201,20 @@ impl BitvSet {
1200
1201
/// let a = BitvSet::from_bitv(from_bytes([0b01101000]));
1201
1202
/// let b = BitvSet::from_bitv(from_bytes([0b10100000]));
1202
1203
///
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) {
1205
1206
/// println!("{}", x);
1206
1207
/// }
1207
1208
/// ```
1208
1209
#[ 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 > {
1211
1211
TwoBitPositions {
1212
1212
set : self ,
1213
1213
other : other,
1214
- merge : |w1, w2| w1 & w2,
1214
+ merge : |w1, w2| w1 ^ w2,
1215
1215
current_word : 0 ,
1216
1216
next_idx : 0
1217
- } . take ( min )
1217
+ }
1218
1218
}
1219
1219
1220
1220
/// Union in-place with the specified other bit vector.
0 commit comments