Closed
Description
Feature gate: #![feature(map_first_last)]
Public API
impl<T> BTreeSet<T> {
pub fn first(&self) -> Option<&T> where T: Ord;
pub fn last(&self) -> Option<&T> where T: Ord;
pub fn pop_first(&mut self) -> Option<T> where T: Ord;
pub fn pop_last(&mut self) -> Option<T> where T: Ord;
}
impl<K, V> BTreeMap<K, V> {
pub fn first_key_value(&self) -> Option<(&K, &V)> where K: Ord;
pub fn last_key_value(&self) -> Option<(&K, &V)> where K: Ord;
pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord;
pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord;
pub fn pop_first(&mut self) -> Option<(K, V)> where K: Ord;
pub fn pop_last(&mut self) -> Option<(K, V)> where K: Ord;
}
Steps / History
- Implementation: proposal for BTreeMap/Set min/max, #62924 #65637
- Changes: BTreeMap first last proposal tweaks #70850
- Final commenting period (FCP)
- Stabilization PR
Unresolved Questions
- Naming (min/max, first/last, front/back, .. ?)
- For BTreeMap: Separate entry and pair (and just-value) functions?
Original issue title: Finding minimum/maximum element in BTreeMap does twice the required amount of computation
Original issue text:
The standard way of finding the minimum element in BTreeMap is tree_map.iter().next()
The iter()
function creates a btree_map::Iter
, which finds both the minimum and maximum element to create its internal instance of btree_map::Range
.
This is unnecessary, and a BTreeMap::get_min
or similar function could be provided, which would just internally call the first_leaf_edge
private function, without needing to call last_leaf_edge
.
Ditto for finding the maximum element.
Metadata
Assignees
Labels
Area: `std::collection`Category: An issue tracking the progress of sth. like the implementation of an RFCIssue: Problems and improvements with respect to performance of generated code.Relevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.
Activity