Closed alok closed 1 year ago
Since the iterators are sorted and double-ended, can't you just do .iter().next()
for .min()
and .iter().next_back()
for .max()
? Come to think of it, the iterators could even override the iterator .min()
and .max()
methods to be O(1)
...
The requested methods have been stabilized in 1.66.0 (first*
and last*
on BTreeMap
/BTreeSet
).
Since trees are naturally based on ordered types, it would be nice to have a method to access the min and max values of a tree (or keys in the case of a treemap). This isn't high priority, but is something I noticed when trying to implement some data structures in Rust.