11//! A priority queue implemented with a binary heap.
22//!
3- //! Insertion and popping the largest element have `O(log n )` time complexity.
3+ //! Insertion and popping the largest element have `O(log(n) )` time complexity.
44//! Checking the largest element is `O(1)`. Converting a vector to a binary heap
55//! can be done in-place, and has `O(n)` complexity. A binary heap can also be
6- //! converted to a sorted vector in-place, allowing it to be used for an `O(n
7- //! log n)` in-place heapsort.
6+ //! converted to a sorted vector in-place, allowing it to be used for an `O(n * log(n))`
7+ //! in-place heapsort.
88//!
99//! # Examples
1010//!
@@ -233,9 +233,9 @@ use super::SpecExtend;
233233///
234234/// # Time complexity
235235///
236- /// | [push] | [pop] | [peek]/[peek\_mut] |
237- /// |--------|----------|--------------------|
238- /// | O(1)~ | O(log n ) | O(1) |
236+ /// | [push] | [pop] | [peek]/[peek\_mut] |
237+ /// |--------|----------- |--------------------|
238+ /// | O(1)~ | O(log(n) ) | O(1) |
239239///
240240/// The value for `push` is an expected cost; the method documentation gives a
241241/// more detailed analysis.
@@ -398,7 +398,7 @@ impl<T: Ord> BinaryHeap<T> {
398398 ///
399399 /// # Time complexity
400400 ///
401- /// Cost is O(1) in the worst case.
401+ /// Cost is ` O(1)` in the worst case.
402402 #[ stable( feature = "binary_heap_peek_mut" , since = "1.12.0" ) ]
403403 pub fn peek_mut ( & mut self ) -> Option < PeekMut < ' _ , T > > {
404404 if self . is_empty ( ) { None } else { Some ( PeekMut { heap : self , sift : true } ) }
@@ -422,8 +422,7 @@ impl<T: Ord> BinaryHeap<T> {
422422 ///
423423 /// # Time complexity
424424 ///
425- /// The worst case cost of `pop` on a heap containing *n* elements is O(log
426- /// n).
425+ /// The worst case cost of `pop` on a heap containing *n* elements is `O(log(n))`.
427426 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
428427 pub fn pop ( & mut self ) -> Option < T > {
429428 self . data . pop ( ) . map ( |mut item| {
@@ -456,15 +455,15 @@ impl<T: Ord> BinaryHeap<T> {
456455 ///
457456 /// The expected cost of `push`, averaged over every possible ordering of
458457 /// the elements being pushed, and over a sufficiently large number of
459- /// pushes, is O(1). This is the most meaningful cost metric when pushing
458+ /// pushes, is ` O(1)` . This is the most meaningful cost metric when pushing
460459 /// elements that are *not* already in any sorted pattern.
461460 ///
462461 /// The time complexity degrades if elements are pushed in predominantly
463462 /// ascending order. In the worst case, elements are pushed in ascending
464- /// sorted order and the amortized cost per push is O(log n) against a heap
463+ /// sorted order and the amortized cost per push is ` O(log(n))` against a heap
465464 /// containing *n* elements.
466465 ///
467- /// The worst case cost of a *single* call to `push` is O(n). The worst case
466+ /// The worst case cost of a *single* call to `push` is ` O(n)` . The worst case
468467 /// occurs when capacity is exhausted and needs a resize. The resize cost
469468 /// has been amortized in the previous figures.
470469 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -623,7 +622,7 @@ impl<T: Ord> BinaryHeap<T> {
623622
624623 // `rebuild` takes O(len1 + len2) operations
625624 // and about 2 * (len1 + len2) comparisons in the worst case
626- // while `extend` takes O(len2 * log_2 (len1)) operations
625+ // while `extend` takes O(len2 * log (len1)) operations
627626 // and about 1 * len2 * log_2(len1) comparisons in the worst case,
628627 // assuming len1 >= len2.
629628 #[ inline]
@@ -644,7 +643,7 @@ impl<T: Ord> BinaryHeap<T> {
644643 /// The remaining elements will be removed on drop in heap order.
645644 ///
646645 /// Note:
647- /// * `.drain_sorted()` is O(n lg n) ; much slower than `.drain()`.
646+ /// * `.drain_sorted()` is ` O(n * log(n))` ; much slower than `.drain()`.
648647 /// You should use the latter for most cases.
649648 ///
650649 /// # Examples
@@ -729,7 +728,7 @@ impl<T> BinaryHeap<T> {
729728 ///
730729 /// # Time complexity
731730 ///
732- /// Cost is O(1) in the worst case.
731+ /// Cost is ` O(1)` in the worst case.
733732 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
734733 pub fn peek ( & self ) -> Option < & T > {
735734 self . data . get ( 0 )
0 commit comments