@@ -68,6 +68,7 @@ struct MaskWords<'a> {
68
68
69
69
impl < ' a > Iterator < ( uint , uint ) > for MaskWords < ' a > {
70
70
/// Returns (offset, word)
71
+ #[ inline]
71
72
fn next < ' a > ( & ' a mut self ) -> Option < ( uint , uint ) > {
72
73
let ret = self . next_word ;
73
74
match ret {
@@ -347,6 +348,7 @@ pub fn from_fn(len: uint, f: |index: uint| -> bool) -> Bitv {
347
348
}
348
349
349
350
impl ops:: Index < uint , bool > for Bitv {
351
+ #[ inline]
350
352
fn index ( & self , i : & uint ) -> bool {
351
353
self . get ( * i)
352
354
}
@@ -453,23 +455,27 @@ impl Default for BitvSet {
453
455
454
456
impl BitvSet {
455
457
/// Creates a new bit vector set with initially no contents
458
+ #[ inline]
456
459
pub fn new ( ) -> BitvSet {
457
460
BitvSet ( Bitv :: new ( 0 , false ) )
458
461
}
459
462
460
463
/// Creates a new bit vector set from the given bit vector
464
+ #[ inline]
461
465
pub fn from_bitv ( bitv : Bitv ) -> BitvSet {
462
466
BitvSet ( bitv)
463
467
}
464
468
465
469
/// Returns the capacity in bits for this bit vector. Inserting any
466
470
/// element less than this amount will not trigger a resizing.
471
+ #[ inline]
467
472
pub fn capacity ( & self ) -> uint {
468
473
let & BitvSet ( ref bitv) = self ;
469
474
bitv. storage . len ( ) * uint:: BITS
470
475
}
471
476
472
477
/// Consumes this set to return the underlying bit vector
478
+ #[ inline]
473
479
pub fn unwrap ( self ) -> Bitv {
474
480
let BitvSet ( bitv) = self ;
475
481
bitv
@@ -515,29 +521,37 @@ impl BitvSet {
515
521
}
516
522
517
523
/// Union in-place with the specified other bit vector
524
+ #[ inline]
518
525
pub fn union_with ( & mut self , other : & BitvSet ) {
519
526
self . other_op ( other, |w1, w2| w1 | w2) ;
520
527
}
521
528
522
529
/// Intersect in-place with the specified other bit vector
530
+ #[ inline]
523
531
pub fn intersect_with ( & mut self , other : & BitvSet ) {
524
532
self . other_op ( other, |w1, w2| w1 & w2) ;
525
533
}
526
534
527
535
/// Difference in-place with the specified other bit vector
536
+ #[ inline]
528
537
pub fn difference_with ( & mut self , other : & BitvSet ) {
529
538
self . other_op ( other, |w1, w2| w1 & !w2) ;
530
539
}
531
540
532
541
/// Symmetric difference in-place with the specified other bit vector
542
+ #[ inline]
533
543
pub fn symmetric_difference_with ( & mut self , other : & BitvSet ) {
534
544
self . other_op ( other, |w1, w2| w1 ^ w2) ;
535
545
}
536
546
547
+ /// Iterator over each uint stored in the BitvSet
548
+ #[ inline]
537
549
pub fn iter < ' a > ( & ' a self ) -> BitPositions < ' a > {
538
550
BitPositions { set : self , next_idx : 0 }
539
551
}
540
552
553
+ /// Iterator over each uint stored in the `self` setminus `other`
554
+ #[ inline]
541
555
pub fn difference < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
542
556
TwoBitPositions {
543
557
set : self ,
@@ -548,6 +562,8 @@ impl BitvSet {
548
562
}
549
563
}
550
564
565
+ /// Iterator over each uint stored in the symmetric difference of `self` and `other`
566
+ #[ inline]
551
567
pub fn symmetric_difference < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
552
568
TwoBitPositions {
553
569
set : self ,
@@ -558,6 +574,8 @@ impl BitvSet {
558
574
}
559
575
}
560
576
577
+ /// Iterator over each uint stored in `self` intersect `other`
578
+ #[ inline]
561
579
pub fn intersection < ' a > ( & ' a self , other : & ' a BitvSet ) -> Take < TwoBitPositions < ' a > > {
562
580
let min = cmp:: min ( self . capacity ( ) , other. capacity ( ) ) ;
563
581
TwoBitPositions {
@@ -569,6 +587,8 @@ impl BitvSet {
569
587
} . take ( min)
570
588
}
571
589
590
+ /// Iterator over each uint stored in `self` union `other`
591
+ #[ inline]
572
592
pub fn union < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
573
593
TwoBitPositions {
574
594
set : self ,
@@ -612,18 +632,21 @@ impl Collection for BitvSet {
612
632
}
613
633
614
634
impl Mutable for BitvSet {
635
+ #[ inline]
615
636
fn clear ( & mut self ) {
616
637
let & BitvSet ( ref mut bitv) = self ;
617
638
bitv. clear ( ) ;
618
639
}
619
640
}
620
641
621
642
impl Set < uint > for BitvSet {
643
+ #[ inline]
622
644
fn contains ( & self , value : & uint ) -> bool {
623
645
let & BitvSet ( ref bitv) = self ;
624
646
* value < bitv. nbits && bitv. get ( * value)
625
647
}
626
648
649
+ #[ inline]
627
650
fn is_disjoint ( & self , other : & BitvSet ) -> bool {
628
651
self . intersection ( other) . count ( ) > 0
629
652
}
@@ -647,6 +670,7 @@ impl Set<uint> for BitvSet {
647
670
return true ;
648
671
}
649
672
673
+ #[ inline]
650
674
fn is_superset ( & self , other : & BitvSet ) -> bool {
651
675
other. is_subset ( self )
652
676
}
@@ -737,7 +761,6 @@ pub struct TwoBitPositions<'a> {
737
761
}
738
762
739
763
impl < ' a > Iterator < uint > for BitPositions < ' a > {
740
- #[ inline]
741
764
fn next ( & mut self ) -> Option < uint > {
742
765
while self . next_idx < self . set . capacity ( ) {
743
766
let idx = self . next_idx ;
@@ -751,13 +774,13 @@ impl<'a> Iterator<uint> for BitPositions<'a> {
751
774
return None ;
752
775
}
753
776
777
+ #[ inline]
754
778
fn size_hint ( & self ) -> ( uint , Option < uint > ) {
755
779
( 0 , Some ( self . set . capacity ( ) - self . next_idx ) )
756
780
}
757
781
}
758
782
759
783
impl < ' a > Iterator < uint > for TwoBitPositions < ' a > {
760
- #[ inline]
761
784
fn next ( & mut self ) -> Option < uint > {
762
785
while self . next_idx < self . set . capacity ( ) ||
763
786
self . next_idx < self . other . capacity ( ) {
@@ -785,6 +808,7 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
785
808
return None ;
786
809
}
787
810
811
+ #[ inline]
788
812
fn size_hint ( & self ) -> ( uint , Option < uint > ) {
789
813
let cap = cmp:: max ( self . set . capacity ( ) , self . other . capacity ( ) ) ;
790
814
( 0 , Some ( cap - self . next_idx ) )
0 commit comments