pub struct LazyList<T: Clone> { /* private fields */ }
Expand description
lazy-cogs implementation of a LinkedList. It’s a collection meant to be used when you need to work with the whole data, not it’s elements
Cloning a LazyList is always O(1). Modifing or getting piecies of data is O(n). Actually, pushing and popping into/from the front or back of the list may be O(1) is the list is mutable
Implementations§
Source§impl<T: Clone> LazyList<T>
impl<T: Clone> LazyList<T>
Sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Obtains a reference to a specific value in the list
If the index is out of range it returns None
This operation is always O(n)
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut T>
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
Obtains a mutable reference to a specific value in the list
If the index is out of range it returns None
This operation is protected, it means, that the other clones aren’t affected
Sourcepub fn get_lazy(&self, index: usize) -> Option<Lc<T>>
pub fn get_lazy(&self, index: usize) -> Option<Lc<T>>
Obtains a lazy clone to a specific value in the list
Sourcepub fn set(&mut self, index: usize, value: T) -> Result<(), ()>
pub fn set(&mut self, index: usize, value: T) -> Result<(), ()>
Changes the value at a given position of the list
Returns Ok(()) if the index is in-bounds and Err(()) if not
Sourcepub fn push_front(&mut self, value: T)
pub fn push_front(&mut self, value: T)
Pushes a new element at the beginning of the list
Sourcepub fn pop_back_lazy(&mut self) -> Option<Lc<T>>
pub fn pop_back_lazy(&mut self) -> Option<Lc<T>>
Pops an element from the end of the list and returns the lazy clone to the value
Sourcepub fn pop_front_lazy(&mut self) -> Option<Lc<T>>
pub fn pop_front_lazy(&mut self) -> Option<Lc<T>>
Pops an element from the beginning of the list and returns the lazy clone to the value
Sourcepub fn pop_back(&mut self) -> Option<T>
pub fn pop_back(&mut self) -> Option<T>
Pops an element from the end of the list and returns the lazy clone to the value
Sourcepub fn pop_front(&mut self) -> Option<T>
pub fn pop_front(&mut self) -> Option<T>
Pops an element from the beginning of the list and returns the lazy clone to the value
Sourcepub fn front(&self) -> Option<&T>
pub fn front(&self) -> Option<&T>
Returns a reference to the first element of the list
Return None
if the list is empty
Sourcepub fn front_mut(&mut self) -> Option<&mut T>
pub fn front_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the first element of the list
Return None
if the list is empty
This operation is protected, it means, that the other clones aren’t affected
Sourcepub fn front_lazy(&self) -> Option<Lc<T>>
pub fn front_lazy(&self) -> Option<Lc<T>>
Returns a lazy clone to the first element of the list
Returns None
if the list is empty
Sourcepub fn back(&self) -> Option<&T>
pub fn back(&self) -> Option<&T>
Returns a reference to the last element of the list
Return None
if the list is empty
Sourcepub fn back_mut(&mut self) -> Option<&mut T>
pub fn back_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the last element of the list
Return None
if the list is empty
This operation is protected, it means, that the other clones aren’t affected
Sourcepub fn back_lazy(&self) -> Option<Lc<T>>
pub fn back_lazy(&self) -> Option<Lc<T>>
Returns a lazy clone to the last element of the list
Returns None
if the list is empty