Rust: Doubly Linked List
No, this is not a post about how to implement doubly linked list in rust.
Or ir could be a very short post, since doubly linked list in built-in the std::collection
as LinkedList
Following functions are available:
new
: Creates new/empty linked listpush_back
: Adds an element to the listpush_front
: Since this is doubly linked list, element can be added at the beginning as well. Nice!pop_back
andpop_front
: Remove an element from the listclear
: empty the entire listappend
: Append one list to another to make bigger list. One that got appended becomes empty though.contains
: Searches through the list for the element 1- There are
iter
,iter_mut
andlen
as well.
[Documentation](https://doc.rust-lang.org/std/collections/ struct.LinkedList.html) is easy to understand
-
Since this is a Linked List, compute time is
O(n)
↩︎