Skip to content

Commit

Permalink
docs(cordyceps): fix wrong time complexity notes (#430)
Browse files Browse the repository at this point in the history
Currently, the `cordyceps::List` documentation states the time
complexity of certain methods, such as `pop_front`, `pop_back`,
`push_front`, and `push_back`, are *O*(*n*), while they are actually
*O*(1). This commit fixes the incorrect docs.

Fixes #429
  • Loading branch information
hawkw committed May 12, 2023
1 parent ef46f9e commit 9c59525
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cordyceps/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {
/// This reuses all the nodes from `other` and moves them into `self`. After
/// this operation, `other` becomes empty.
///
/// This operation should compute in *O*(1) time and *O*(1) memory.
/// This operation should complete in *O*(1) time and *O*(1) memory.
pub fn append(&mut self, other: &mut Self) {
// TODO(eliza): this could be rewritten to use `let ... else` when
// that's supported on `cordyceps`' MSRV.
Expand Down Expand Up @@ -345,7 +345,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {
/// Returns everything after the given index (including the node at that
/// index), or `None` if the index is greater than the list's [length].
///
/// This operation should compute in *O*(*n*) time.
/// This operation should complete in *O*(*n*) time.
///
/// # Returns
///
Expand Down Expand Up @@ -397,7 +397,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {
/// Returns everything after the given index (including the node at that
/// index).
///
/// This operation should compute in *O*(1) time and *O*(1) memory.
/// This operation should complete in *O*(*n*) time.
///
/// # Panics
///
Expand Down Expand Up @@ -520,7 +520,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {

/// Removes an item from the tail of the list.
///
/// This operation should compute in *O*(*n*) time.
/// This operation should complete in *O*(1) time.
///
/// This returns a [`Handle`] that owns the popped element. Dropping the
/// [`Handle`] will drop the element.
Expand Down Expand Up @@ -554,7 +554,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {

/// Remove an item from the head of the list.
///
/// This operation should compute in *O*(*n*) time.
/// This operation should complete in *O*(1) time.
///
/// This returns a [`Handle`] that owns the popped element. Dropping the
/// [`Handle`] will drop the element.
Expand All @@ -580,7 +580,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {

/// Appends an item to the tail of the list.
///
/// This operation should compute in *O*(*n*) time.
/// This operation should complete in *O*(1) time.
///
/// This takes a [`Handle`] that owns the appended `item`. While the element
/// is in the list, it is owned by the list, and will be dropped when the
Expand Down Expand Up @@ -609,7 +609,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {

/// Appends an item to the head of the list.
///
/// This operation should compute in *O*(*n*) time.
/// This operation should complete in *O*(1) time.
///
/// This takes a [`Handle`] that owns the appended `item`. While the element
/// is in the list, it is owned by the list, and will be dropped when the
Expand Down Expand Up @@ -727,6 +727,8 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> {

/// Remove an arbitrary node from the list.
///
/// This operation should complete in *O*(1) time.
///
/// This returns a [`Handle`] that owns the popped element. Dropping the
/// [`Handle`] will drop the element.
///
Expand Down

0 comments on commit 9c59525

Please sign in to comment.