Skip to content

Commit 0fa4349

Browse files
Rollup merge of #89210 - Takashiidobe:master, r=kennytm
Add missing time complexities to linked_list.rs Most functions in LinkedList have time complexities in their description: Like push front: ``` Adds an element first in the list. This operation should compute in O(1) time. ``` Time complexities were missing for the following, so I've added them in this PR: contains: O(n) front: O(1) front_mut: O(1) back: O(1) back_mut: O(1)
2 parents 7ade6ed + cebba31 commit 0fa4349

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/alloc/src/collections/linked_list.rs

+10
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ impl<T> LinkedList<T> {
631631
/// Returns `true` if the `LinkedList` contains an element equal to the
632632
/// given value.
633633
///
634+
/// This operation should compute in *O*(*n*) time.
635+
///
634636
/// # Examples
635637
///
636638
/// ```
@@ -656,6 +658,8 @@ impl<T> LinkedList<T> {
656658
/// Provides a reference to the front element, or `None` if the list is
657659
/// empty.
658660
///
661+
/// This operation should compute in *O*(1) time.
662+
///
659663
/// # Examples
660664
///
661665
/// ```
@@ -676,6 +680,8 @@ impl<T> LinkedList<T> {
676680
/// Provides a mutable reference to the front element, or `None` if the list
677681
/// is empty.
678682
///
683+
/// This operation should compute in *O*(1) time.
684+
///
679685
/// # Examples
680686
///
681687
/// ```
@@ -702,6 +708,8 @@ impl<T> LinkedList<T> {
702708
/// Provides a reference to the back element, or `None` if the list is
703709
/// empty.
704710
///
711+
/// This operation should compute in *O*(1) time.
712+
///
705713
/// # Examples
706714
///
707715
/// ```
@@ -722,6 +730,8 @@ impl<T> LinkedList<T> {
722730
/// Provides a mutable reference to the back element, or `None` if the list
723731
/// is empty.
724732
///
733+
/// This operation should compute in *O*(1) time.
734+
///
725735
/// # Examples
726736
///
727737
/// ```

0 commit comments

Comments
 (0)