Skip to content

Commit 7048e17

Browse files
committed
DOC: Add time/space bound in doc for sort_by
1 parent 21ba2a8 commit 7048e17

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,8 @@ impl<K, V, S> OrderMap<K, V, S>
10501050
}
10511051

10521052
/// Sort the map’s key-value pairs by the default ordering of the keys.
1053+
///
1054+
/// See `sort_by` for details.
10531055
pub fn sort_keys(&mut self)
10541056
where K: Ord,
10551057
{
@@ -1061,6 +1063,8 @@ impl<K, V, S> OrderMap<K, V, S>
10611063
///
10621064
/// The comparison function receives two key and value pairs to compare (you
10631065
/// can sort by keys or values or their combination as needed).
1066+
///
1067+
/// Computes in **O(n log n)** time and **O(n)** space. The sort is stable.
10641068
pub fn sort_by<F>(&mut self, mut compare: F)
10651069
where F: FnMut(&K, &V, &K, &V) -> Ordering,
10661070
{

src/set.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,17 @@ impl<T, S> OrderSet<T, S>
343343
}
344344

345345
/// Sort the set’s values by their default ordering.
346+
///
347+
/// See `sort_by` for details.
346348
pub fn sort(&mut self)
347349
where T: Ord,
348350
{
349351
self.map.sort_keys()
350352
}
351353

352354
/// Sort the set’s values in place using the comparison function `compare`.
355+
///
356+
/// Computes in **O(n log n)** time and **O(n)** space. The sort is stable.
353357
pub fn sort_by<F>(&mut self, mut compare: F)
354358
where F: FnMut(&T, &T) -> Ordering,
355359
{

0 commit comments

Comments
 (0)