@@ -75,6 +75,8 @@ use std::hash;
75
75
76
76
use vec:: Vec ;
77
77
78
+ // FIXME(conventions): look, we just need to refactor this whole thing. Inside and out.
79
+
78
80
type MatchWords < ' a > = Chain < MaskWords < ' a > , Skip < Take < Enumerate < Repeat < u32 > > > > > ;
79
81
// Take two BitV's, and return iterators of their words, where the shorter one
80
82
// has been padded with 0's
@@ -216,6 +218,7 @@ impl Bitv {
216
218
/// use std::collections::Bitv;
217
219
/// let mut bv = Bitv::new();
218
220
/// ```
221
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
219
222
pub fn new ( ) -> Bitv {
220
223
Bitv { storage : Vec :: new ( ) , nbits : 0 }
221
224
}
@@ -613,6 +616,7 @@ impl Bitv {
613
616
/// bv.truncate(2);
614
617
/// assert!(bv.eq_vec([false, true]));
615
618
/// ```
619
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
616
620
pub fn truncate ( & mut self , len : uint ) {
617
621
if len < self . len ( ) {
618
622
self . nbits = len;
@@ -760,14 +764,17 @@ impl Bitv {
760
764
761
765
/// Return the total number of bits in this vector
762
766
#[ inline]
767
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
763
768
pub fn len ( & self ) -> uint { self . nbits }
764
769
765
770
/// Returns true if there are no bits in this vector
766
771
#[ inline]
772
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
767
773
pub fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
768
774
769
775
/// Clears all bits in this vector.
770
776
#[ inline]
777
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
771
778
pub fn clear ( & mut self ) {
772
779
for w in self . storage . iter_mut ( ) { * w = 0u32 ; }
773
780
}
@@ -849,8 +856,7 @@ impl Clone for Bitv {
849
856
#[ inline]
850
857
fn clone_from ( & mut self , source : & Bitv ) {
851
858
self . nbits = source. nbits ;
852
- self . storage . reserve ( source. storage . len ( ) ) ;
853
- for ( i, w) in self . storage . iter_mut ( ) . enumerate ( ) { * w = source. storage [ i] ; }
859
+ self . storage . clone_from ( & source. storage ) ;
854
860
}
855
861
}
856
862
@@ -1052,6 +1058,7 @@ impl BitvSet {
1052
1058
/// let mut s = BitvSet::new();
1053
1059
/// ```
1054
1060
#[ inline]
1061
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1055
1062
pub fn new ( ) -> BitvSet {
1056
1063
BitvSet ( Bitv :: new ( ) )
1057
1064
}
@@ -1067,6 +1074,7 @@ impl BitvSet {
1067
1074
/// assert!(s.capacity() >= 100);
1068
1075
/// ```
1069
1076
#[ inline]
1077
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1070
1078
pub fn with_capacity ( nbits : uint ) -> BitvSet {
1071
1079
let bitv = Bitv :: with_capacity ( nbits, false ) ;
1072
1080
BitvSet :: from_bitv ( bitv)
@@ -1106,6 +1114,7 @@ impl BitvSet {
1106
1114
/// assert!(s.capacity() >= 100);
1107
1115
/// ```
1108
1116
#[ inline]
1117
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1109
1118
pub fn capacity ( & self ) -> uint {
1110
1119
let & BitvSet ( ref bitv) = self ;
1111
1120
bitv. capacity ( )
@@ -1212,6 +1221,7 @@ impl BitvSet {
1212
1221
/// println!("new capacity: {}", s.capacity());
1213
1222
/// ```
1214
1223
#[ inline]
1224
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1215
1225
pub fn shrink_to_fit ( & mut self ) {
1216
1226
let & BitvSet ( ref mut bitv) = self ;
1217
1227
// Obtain original length
@@ -1240,6 +1250,7 @@ impl BitvSet {
1240
1250
/// }
1241
1251
/// ```
1242
1252
#[ inline]
1253
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1243
1254
pub fn iter < ' a > ( & ' a self ) -> BitPositions < ' a > {
1244
1255
BitPositions { set : self , next_idx : 0 u}
1245
1256
}
@@ -1262,6 +1273,7 @@ impl BitvSet {
1262
1273
/// }
1263
1274
/// ```
1264
1275
#[ inline]
1276
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1265
1277
pub fn union < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
1266
1278
TwoBitPositions {
1267
1279
set : self ,
@@ -1290,6 +1302,7 @@ impl BitvSet {
1290
1302
/// }
1291
1303
/// ```
1292
1304
#[ inline]
1305
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1293
1306
pub fn intersection < ' a > ( & ' a self , other : & ' a BitvSet ) -> Take < TwoBitPositions < ' a > > {
1294
1307
let min = cmp:: min ( self . capacity ( ) , other. capacity ( ) ) ;
1295
1308
TwoBitPositions {
@@ -1326,6 +1339,7 @@ impl BitvSet {
1326
1339
/// }
1327
1340
/// ```
1328
1341
#[ inline]
1342
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1329
1343
pub fn difference < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
1330
1344
TwoBitPositions {
1331
1345
set : self ,
@@ -1355,6 +1369,7 @@ impl BitvSet {
1355
1369
/// }
1356
1370
/// ```
1357
1371
#[ inline]
1372
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1358
1373
pub fn symmetric_difference < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
1359
1374
TwoBitPositions {
1360
1375
set : self ,
@@ -1473,27 +1488,31 @@ impl BitvSet {
1473
1488
1474
1489
/// Return the number of set bits in this set.
1475
1490
#[ inline]
1491
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1476
1492
pub fn len ( & self ) -> uint {
1477
1493
let & BitvSet ( ref bitv) = self ;
1478
1494
bitv. storage . iter ( ) . fold ( 0 , |acc, & n| acc + n. count_ones ( ) )
1479
1495
}
1480
1496
1481
1497
/// Returns whether there are no bits set in this set
1482
1498
#[ inline]
1499
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1483
1500
pub fn is_empty ( & self ) -> bool {
1484
1501
let & BitvSet ( ref bitv) = self ;
1485
1502
bitv. storage . iter ( ) . all ( |& n| n == 0 )
1486
1503
}
1487
1504
1488
1505
/// Clears all bits in this set
1489
1506
#[ inline]
1507
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1490
1508
pub fn clear ( & mut self ) {
1491
1509
let & BitvSet ( ref mut bitv) = self ;
1492
1510
bitv. clear ( ) ;
1493
1511
}
1494
1512
1495
1513
/// Returns `true` if this set contains the specified integer.
1496
1514
#[ inline]
1515
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1497
1516
pub fn contains ( & self , value : & uint ) -> bool {
1498
1517
let & BitvSet ( ref bitv) = self ;
1499
1518
* value < bitv. nbits && bitv. get ( * value)
@@ -1502,12 +1521,14 @@ impl BitvSet {
1502
1521
/// Returns `true` if the set has no elements in common with `other`.
1503
1522
/// This is equivalent to checking for an empty intersection.
1504
1523
#[ inline]
1524
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1505
1525
pub fn is_disjoint ( & self , other : & BitvSet ) -> bool {
1506
1526
self . intersection ( other) . next ( ) . is_none ( )
1507
1527
}
1508
1528
1509
1529
/// Returns `true` if the set is a subset of another.
1510
1530
#[ inline]
1531
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1511
1532
pub fn is_subset ( & self , other : & BitvSet ) -> bool {
1512
1533
let & BitvSet ( ref self_bitv) = self ;
1513
1534
let & BitvSet ( ref other_bitv) = other;
@@ -1521,12 +1542,14 @@ impl BitvSet {
1521
1542
1522
1543
/// Returns `true` if the set is a superset of another.
1523
1544
#[ inline]
1545
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1524
1546
pub fn is_superset ( & self , other : & BitvSet ) -> bool {
1525
1547
other. is_subset ( self )
1526
1548
}
1527
1549
1528
1550
/// Adds a value to the set. Returns `true` if the value was not already
1529
1551
/// present in the set.
1552
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1530
1553
pub fn insert ( & mut self , value : uint ) -> bool {
1531
1554
if self . contains ( & value) {
1532
1555
return false ;
@@ -1545,6 +1568,7 @@ impl BitvSet {
1545
1568
1546
1569
/// Removes a value from the set. Returns `true` if the value was
1547
1570
/// present in the set.
1571
+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1548
1572
pub fn remove ( & mut self , value : & uint ) -> bool {
1549
1573
if !self . contains ( value) {
1550
1574
return false ;
0 commit comments