@@ -579,21 +579,21 @@ impl RoaringBitmap {
579579 None
580580 }
581581
582- /// Removes the specified number of elements from the top .
582+ /// Removes the `n` smallests values from this bitmap .
583583 ///
584584 /// # Examples
585585 ///
586586 /// ```rust
587587 /// use roaring::RoaringBitmap;
588588 ///
589589 /// let mut rb = RoaringBitmap::from_iter([1, 5, 7, 9]);
590- /// rb.remove_front (2);
590+ /// rb.remove_smallest (2);
591591 /// assert_eq!(rb, RoaringBitmap::from_iter([7, 9]));
592592 ///
593593 /// let mut rb = RoaringBitmap::from_iter([1, 3, 7, 9]);
594- /// rb.remove_front (2);
594+ /// rb.remove_smallest (2);
595595 /// assert_eq!(rb, RoaringBitmap::from_iter([7, 9]));
596- pub fn remove_front ( & mut self , mut n : u64 ) {
596+ pub fn remove_smallest ( & mut self , mut n : u64 ) {
597597 // remove containers up to the front of the target
598598 let position = self . containers . iter ( ) . position ( |container| {
599599 let container_len = container. len ( ) ;
@@ -611,23 +611,23 @@ impl RoaringBitmap {
611611 // remove data in containers if there are still targets for deletion
612612 if n > 0 && !self . containers . is_empty ( ) {
613613 // container immediately before should have been deleted, so the target is 0 index
614- self . containers [ 0 ] . remove_front ( n) ;
614+ self . containers [ 0 ] . remove_smallest ( n) ;
615615 }
616616 }
617617
618- /// Removes the specified number of elements from the tail .
618+ /// Removes the `n` biggests values from this bitmap .
619619 ///
620620 /// # Examples
621621 ///
622622 /// ```rust
623623 /// use roaring::RoaringBitmap;
624624 ///
625625 /// let mut rb = RoaringBitmap::from_iter([1, 5, 7, 9]);
626- /// rb.remove_back (2);
626+ /// rb.remove_biggest (2);
627627 /// assert_eq!(rb, RoaringBitmap::from_iter([1, 5]));
628- /// rb.remove_back (1);
628+ /// rb.remove_biggest (1);
629629 /// assert_eq!(rb, RoaringBitmap::from_iter([1]));
630- pub fn remove_back ( & mut self , mut n : u64 ) {
630+ pub fn remove_biggest ( & mut self , mut n : u64 ) {
631631 // remove containers up to the back of the target
632632 let position = self . containers . iter ( ) . rposition ( |container| {
633633 let container_len = container. len ( ) ;
@@ -642,7 +642,7 @@ impl RoaringBitmap {
642642 if let Some ( position) = position {
643643 self . containers . drain ( position + 1 ..) ;
644644 if n > 0 && !self . containers . is_empty ( ) {
645- self . containers [ position] . remove_back ( n) ;
645+ self . containers [ position] . remove_biggest ( n) ;
646646 }
647647 } else {
648648 self . containers . clear ( ) ;
@@ -800,127 +800,127 @@ mod tests {
800800 }
801801
802802 #[ test]
803- fn remove_front_for_vec ( ) {
803+ fn remove_smallest_for_vec ( ) {
804804 let mut bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ;
805- bitmap. remove_front ( 3 ) ;
805+ bitmap. remove_smallest ( 3 ) ;
806806 assert_eq ! ( bitmap. len( ) , 3 ) ;
807807 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 7 , 9 , 11 ] ) ) ;
808808
809809 bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 5 , 7 , 9 , 11 ] ) ;
810- bitmap. remove_front ( 3 ) ;
810+ bitmap. remove_smallest ( 3 ) ;
811811 assert_eq ! ( bitmap. len( ) , 3 ) ;
812812 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 7 , 9 , 11 ] ) ) ;
813813
814814 bitmap = RoaringBitmap :: from_iter ( [ 1 , 3 ] ) ;
815- bitmap. remove_front ( 2 ) ;
815+ bitmap. remove_smallest ( 2 ) ;
816816 assert_eq ! ( bitmap. len( ) , 0 ) ;
817817
818818 bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ;
819- bitmap. remove_front ( 0 ) ;
819+ bitmap. remove_smallest ( 0 ) ;
820820 assert_eq ! ( bitmap. len( ) , 6 ) ;
821821 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ) ;
822822
823823 bitmap = RoaringBitmap :: new ( ) ;
824824 bitmap. insert_range ( 0 ..( 1_u32 << 16 ) + 5 ) ;
825- bitmap. remove_front ( 65537 ) ;
825+ bitmap. remove_smallest ( 65537 ) ;
826826 assert_eq ! ( bitmap. len( ) , 4 ) ;
827827 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 65537 , 65538 , 65539 , 65540 ] ) ) ;
828828
829829 bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 5 , 7 , 9 , 11 ] ) ;
830- bitmap. remove_front ( 7 ) ;
830+ bitmap. remove_smallest ( 7 ) ;
831831 assert_eq ! ( bitmap, RoaringBitmap :: default ( ) ) ;
832832 }
833833
834834 #[ test]
835- fn remove_front_for_bit ( ) {
835+ fn remove_smallest_for_bit ( ) {
836836 let mut bitmap = RoaringBitmap :: new ( ) ;
837837 bitmap. insert_range ( 0 ..4098 ) ;
838- bitmap. remove_front ( 4095 ) ;
838+ bitmap. remove_smallest ( 4095 ) ;
839839 assert_eq ! ( bitmap. len( ) , 3 ) ;
840840 // removed bit to vec
841841 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 4095 , 4096 , 4097 ] ) ) ;
842842
843843 bitmap = RoaringBitmap :: new ( ) ;
844844 bitmap. insert_range ( 0 ..6000 ) ;
845- bitmap. remove_front ( 999 ) ;
845+ bitmap. remove_smallest ( 999 ) ;
846846 assert_eq ! ( bitmap. len( ) , 5001 ) ;
847847
848848 bitmap = RoaringBitmap :: new ( ) ;
849849 bitmap. insert_range ( 0 ..8000 ) ;
850- bitmap. remove_front ( 10 ) ;
850+ bitmap. remove_smallest ( 10 ) ;
851851 assert_eq ! ( bitmap. len( ) , 7990 ) ;
852852
853853 bitmap = RoaringBitmap :: new ( ) ;
854854 bitmap. insert_range ( 0 ..200000 ) ;
855- bitmap. remove_front ( 2000 ) ;
855+ bitmap. remove_smallest ( 2000 ) ;
856856 assert_eq ! ( bitmap. len( ) , 198000 ) ;
857857 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( 2000 ..200000 ) ) ;
858858
859859 bitmap = RoaringBitmap :: new ( ) ;
860860 bitmap. insert_range ( 0 ..2 ) ;
861861 bitmap. insert_range ( 4 ..7 ) ;
862862 bitmap. insert_range ( 1000 ..6000 ) ;
863- bitmap. remove_front ( 30 ) ;
863+ bitmap. remove_smallest ( 30 ) ;
864864 assert_eq ! ( bitmap. len( ) , 4975 ) ;
865865
866866 bitmap = RoaringBitmap :: new ( ) ;
867867 bitmap. insert_range ( 0 ..65535 ) ;
868- bitmap. remove_front ( 0 ) ;
868+ bitmap. remove_smallest ( 0 ) ;
869869 assert_eq ! ( bitmap. len( ) , 65535 ) ;
870870 }
871871
872872 #[ test]
873- fn remove_back_for_bit ( ) {
873+ fn remove_biggest_for_bit ( ) {
874874 let mut bitmap = RoaringBitmap :: new ( ) ;
875875 bitmap. insert_range ( 0 ..5000 ) ;
876- bitmap. remove_back ( 1000 ) ;
876+ bitmap. remove_biggest ( 1000 ) ;
877877 assert_eq ! ( bitmap. len( ) , 4000 ) ;
878878
879879 bitmap = RoaringBitmap :: new ( ) ;
880880 bitmap. insert_range ( 0 ..6000 ) ;
881- bitmap. remove_back ( 1000 ) ;
881+ bitmap. remove_biggest ( 1000 ) ;
882882 assert_eq ! ( bitmap. len( ) , 5000 ) ;
883883
884884 bitmap = RoaringBitmap :: new ( ) ;
885885 bitmap. insert_range ( 0 ..200000 ) ;
886- bitmap. remove_back ( 196000 ) ;
886+ bitmap. remove_biggest ( 196000 ) ;
887887 assert_eq ! ( bitmap. len( ) , 4000 ) ;
888888
889889 bitmap = RoaringBitmap :: new ( ) ;
890890 bitmap. insert_range ( 0 ..200000 ) ;
891- bitmap. remove_back ( 2000 ) ;
891+ bitmap. remove_biggest ( 2000 ) ;
892892 assert_eq ! ( bitmap. len( ) , 198000 ) ;
893893 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( 0 ..198000 ) ) ;
894894
895895 bitmap = RoaringBitmap :: new ( ) ;
896896 bitmap. insert_range ( 0 ..65535 ) ;
897- bitmap. remove_back ( 0 ) ;
897+ bitmap. remove_biggest ( 0 ) ;
898898 assert_eq ! ( bitmap. len( ) , 65535 ) ;
899899 }
900900
901901 #[ test]
902- fn remove_back_for_vec ( ) {
902+ fn remove_biggest_for_vec ( ) {
903903 let mut bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ;
904- bitmap. remove_back ( 2 ) ;
904+ bitmap. remove_biggest ( 2 ) ;
905905 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 1 , 2 , 3 , 7 ] ) ) ;
906906
907907 bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ;
908- bitmap. remove_back ( 6 ) ;
908+ bitmap. remove_biggest ( 6 ) ;
909909 assert_eq ! ( bitmap. len( ) , 0 ) ;
910910
911911 bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ;
912- bitmap. remove_back ( 0 ) ;
912+ bitmap. remove_biggest ( 0 ) ;
913913 assert_eq ! ( bitmap. len( ) , 6 ) ;
914914 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 1 , 2 , 3 , 7 , 9 , 11 ] ) ) ;
915915
916916 bitmap = RoaringBitmap :: new ( ) ;
917917 bitmap. insert_range ( 0 ..( 1_u32 << 16 ) + 5 ) ;
918- bitmap. remove_back ( 65537 ) ;
918+ bitmap. remove_biggest ( 65537 ) ;
919919 assert_eq ! ( bitmap. len( ) , 4 ) ;
920920 assert_eq ! ( bitmap, RoaringBitmap :: from_iter( [ 0 , 1 , 2 , 3 ] ) ) ;
921921
922922 let mut bitmap = RoaringBitmap :: from_iter ( [ 1 , 2 , 3 ] ) ;
923- bitmap. remove_back ( 4 ) ;
923+ bitmap. remove_biggest ( 4 ) ;
924924 assert_eq ! ( bitmap, RoaringBitmap :: default ( ) ) ;
925925 }
926926}
0 commit comments