@@ -600,8 +600,7 @@ impl<K, V> BTreeMap<K, V> {
600600 }
601601 }
602602
603- /// Returns the first key-value pair in the map.
604- /// The key in this pair is the minimum key in the map.
603+ /// Returns the key-value pair with the minimum key in the map.
605604 ///
606605 /// # Examples
607606 ///
@@ -612,22 +611,21 @@ impl<K, V> BTreeMap<K, V> {
612611 /// use std::collections::BTreeMap;
613612 ///
614613 /// let mut map = BTreeMap::new();
615- /// assert_eq!(map.first_key_value (), None);
614+ /// assert_eq!(map.min_key_value (), None);
616615 /// map.insert(1, "b");
617616 /// map.insert(2, "a");
618- /// assert_eq!(map.first_key_value (), Some((&1, &"b")));
617+ /// assert_eq!(map.min_key_value (), Some((&1, &"b")));
619618 /// ```
620619 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
621- pub fn first_key_value ( & self ) -> Option < ( & K , & V ) >
620+ pub fn min_key_value ( & self ) -> Option < ( & K , & V ) >
622621 where
623622 K : Ord ,
624623 {
625624 let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
626625 root_node. first_leaf_edge ( ) . right_kv ( ) . ok ( ) . map ( Handle :: into_kv)
627626 }
628627
629- /// Returns the first entry in the map for in-place manipulation.
630- /// The key of this entry is the minimum key in the map.
628+ /// Returns the entry with the minimum key in the map for in-place manipulation.
631629 ///
632630 /// # Examples
633631 ///
@@ -638,16 +636,16 @@ impl<K, V> BTreeMap<K, V> {
638636 /// let mut map = BTreeMap::new();
639637 /// map.insert(1, "a");
640638 /// map.insert(2, "b");
641- /// if let Some(mut entry) = map.first_entry () {
639+ /// if let Some(mut entry) = map.min_entry () {
642640 /// if *entry.key() > 0 {
643- /// entry.insert("first ");
641+ /// entry.insert("min ");
644642 /// }
645643 /// }
646- /// assert_eq!(*map.get(&1).unwrap(), "first ");
644+ /// assert_eq!(*map.get(&1).unwrap(), "min ");
647645 /// assert_eq!(*map.get(&2).unwrap(), "b");
648646 /// ```
649647 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
650- pub fn first_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > >
648+ pub fn min_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > >
651649 where
652650 K : Ord ,
653651 {
@@ -657,8 +655,7 @@ impl<K, V> BTreeMap<K, V> {
657655 Some ( OccupiedEntry { handle : kv. forget_node_type ( ) , dormant_map, _marker : PhantomData } )
658656 }
659657
660- /// Removes and returns the first element in the map.
661- /// The key of this element is the minimum key that was in the map.
658+ /// Removes and returns the key-value pair with the minimum key in the map.
662659 ///
663660 /// # Examples
664661 ///
@@ -671,21 +668,21 @@ impl<K, V> BTreeMap<K, V> {
671668 /// let mut map = BTreeMap::new();
672669 /// map.insert(1, "a");
673670 /// map.insert(2, "b");
674- /// while let Some((key, _val)) = map.pop_first () {
671+ /// while let Some((key, _val)) = map.pop_min () {
675672 /// assert!(map.iter().all(|(k, _v)| *k > key));
676673 /// }
677674 /// assert!(map.is_empty());
678675 /// ```
679676 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
680- pub fn pop_first ( & mut self ) -> Option < ( K , V ) >
677+ pub fn pop_min ( & mut self ) -> Option < ( K , V ) >
681678 where
682679 K : Ord ,
683680 {
684- self . first_entry ( ) . map ( |entry| entry. remove_entry ( ) )
681+ self . min_entry ( ) . map ( |entry| entry. remove_entry ( ) )
685682 }
686683
687- /// Returns the last key-value pair in the map.
688- /// The key in this pair is the maximum key in the map.
684+ /// Returns the key-value pair with the maximum key in the
685+ /// map. The key in this pair is the maximum key in the map.
689686 ///
690687 /// # Examples
691688 ///
@@ -698,19 +695,18 @@ impl<K, V> BTreeMap<K, V> {
698695 /// let mut map = BTreeMap::new();
699696 /// map.insert(1, "b");
700697 /// map.insert(2, "a");
701- /// assert_eq!(map.last_key_value (), Some((&2, &"a")));
698+ /// assert_eq!(map.max_key_value (), Some((&2, &"a")));
702699 /// ```
703700 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
704- pub fn last_key_value ( & self ) -> Option < ( & K , & V ) >
701+ pub fn max_key_value ( & self ) -> Option < ( & K , & V ) >
705702 where
706703 K : Ord ,
707704 {
708705 let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
709706 root_node. last_leaf_edge ( ) . left_kv ( ) . ok ( ) . map ( Handle :: into_kv)
710707 }
711708
712- /// Returns the last entry in the map for in-place manipulation.
713- /// The key of this entry is the maximum key in the map.
709+ /// Returns the entry with the maximum key in the map for in-place manipulation.
714710 ///
715711 /// # Examples
716712 ///
@@ -721,16 +717,16 @@ impl<K, V> BTreeMap<K, V> {
721717 /// let mut map = BTreeMap::new();
722718 /// map.insert(1, "a");
723719 /// map.insert(2, "b");
724- /// if let Some(mut entry) = map.last_entry () {
720+ /// if let Some(mut entry) = map.max_entry () {
725721 /// if *entry.key() > 0 {
726- /// entry.insert("last ");
722+ /// entry.insert("max ");
727723 /// }
728724 /// }
729725 /// assert_eq!(*map.get(&1).unwrap(), "a");
730- /// assert_eq!(*map.get(&2).unwrap(), "last ");
726+ /// assert_eq!(*map.get(&2).unwrap(), "max ");
731727 /// ```
732728 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
733- pub fn last_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > >
729+ pub fn max_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > >
734730 where
735731 K : Ord ,
736732 {
@@ -740,8 +736,7 @@ impl<K, V> BTreeMap<K, V> {
740736 Some ( OccupiedEntry { handle : kv. forget_node_type ( ) , dormant_map, _marker : PhantomData } )
741737 }
742738
743- /// Removes and returns the last element in the map.
744- /// The key of this element is the maximum key that was in the map.
739+ /// Removes and returns the key-value pair with the maximum key in the map.
745740 ///
746741 /// # Examples
747742 ///
@@ -754,17 +749,17 @@ impl<K, V> BTreeMap<K, V> {
754749 /// let mut map = BTreeMap::new();
755750 /// map.insert(1, "a");
756751 /// map.insert(2, "b");
757- /// while let Some((key, _val)) = map.pop_last () {
752+ /// while let Some((key, _val)) = map.pop_max () {
758753 /// assert!(map.iter().all(|(k, _v)| *k < key));
759754 /// }
760755 /// assert!(map.is_empty());
761756 /// ```
762757 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
763- pub fn pop_last ( & mut self ) -> Option < ( K , V ) >
758+ pub fn pop_max ( & mut self ) -> Option < ( K , V ) >
764759 where
765760 K : Ord ,
766761 {
767- self . last_entry ( ) . map ( |entry| entry. remove_entry ( ) )
762+ self . max_entry ( ) . map ( |entry| entry. remove_entry ( ) )
768763 }
769764
770765 /// Returns `true` if the map contains a value for the specified key.
0 commit comments