logo
pub struct SinglyLinkedList<T> { /* private fields */ }
Expand description

Implementations

Constructs a new, empty SinglyLinkedList<T>.

The list will not allocate until elements are pushed onto it.

Prepends the given element value to the beginning of the container.

Parameters
  • elem - The element to prepend.
Complexity

Constant.

Removes and returns the first element of the container. If there are no elements in the container, return None.

Complexity

Constant.

Inserts an element after the specified position in the container.

If the position is out of bound, returns an Result:Err with the size of the list.

Parameters
  • pos - The index after which the element will be inserted.
  • elem - The element to be inserted.
Complexity

Search time O(n) + O(1).

Removes and returns an element at specified position from the container.

Parameters
  • pos - The index at which the element will be moved.
Complexity

Search time O(n) + constant.

Removes all elements from the container.

Complexity

Linear in the size of the container.

Checks whether the container is empty.

Complexity

Constant.

Gets the number of elements in the container.

Complexity

Linear in the size of the container.

Reverses the order of the elements in the container.

Complexity

Linear in the size of the container.

Creates an iterator that yields immutable reference of each element.

Creates an iterator that yields mutable reference of each element.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Creates a consuming iterator, that is, one that moves each value out of the list (from start to end). The list cannot be used after calling this.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.