pub struct List<T, P = RcK>where
P: SharedPointerKind,{ /* private fields */ }Expand description
A persistent list with structural sharing.
§Complexity
Let n be the number of elements in the list.
§Temporal complexity
| Operation | Average | Worst case |
|---|---|---|
new() | Θ(1) | Θ(1) |
push_front() | Θ(1) | Θ(1) |
drop_first() | Θ(1) | Θ(1) |
reverse() | Θ(n) | Θ(n) |
first() | Θ(1) | Θ(1) |
last() | Θ(1) | Θ(1) |
len() | Θ(1) | Θ(1) |
clone() | Θ(1) | Θ(1) |
| iterator creation | Θ(1) | Θ(1) |
| iterator step | Θ(1) | Θ(1) |
| iterator full | Θ(n) | Θ(n) |
§Implementation details
This is your classic functional list with “cons” and “nil” nodes, with a little extra sauce to make some operations more efficient.
Implementations§
Source§impl<T, P> List<T, P>where
P: SharedPointerKind,
impl<T, P> List<T, P>where
P: SharedPointerKind,
pub fn new_with_ptr_kind() -> List<T, P>
pub fn first(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
pub fn drop_first(&self) -> Option<List<T, P>>
pub fn drop_first_mut(&mut self) -> bool
pub fn push_front(&self, v: T) -> List<T, P>
pub fn push_front_mut(&mut self, v: T)
pub fn reverse(&self) -> List<T, P>
pub fn reverse_mut(&mut self)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Map<IterPtr<'_, T, P>, fn(&SharedPointer<T, P>) -> &T> ⓘ
Trait Implementations§
Source§impl<T, P> Clone for List<T, P>where
P: SharedPointerKind,
impl<T, P> Clone for List<T, P>where
P: SharedPointerKind,
Source§impl<T, P> Default for List<T, P>where
P: SharedPointerKind,
impl<T, P> Default for List<T, P>where
P: SharedPointerKind,
Source§impl<'de, T, P> Deserialize<'de> for List<T, P>where
T: Deserialize<'de>,
P: SharedPointerKind,
impl<'de, T, P> Deserialize<'de> for List<T, P>where
T: Deserialize<'de>,
P: SharedPointerKind,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<List<T, P>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<List<T, P>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T, P> Drop for List<T, P>where
P: SharedPointerKind,
impl<T, P> Drop for List<T, P>where
P: SharedPointerKind,
Source§impl<T, P> FromIterator<T> for List<T, P>where
P: SharedPointerKind,
impl<T, P> FromIterator<T> for List<T, P>where
P: SharedPointerKind,
Source§impl<'a, T, P> IntoIterator for &'a List<T, P>where
P: SharedPointerKind,
impl<'a, T, P> IntoIterator for &'a List<T, P>where
P: SharedPointerKind,
Source§impl<T, P> Ord for List<T, P>where
T: Ord,
P: SharedPointerKind,
impl<T, P> Ord for List<T, P>where
T: Ord,
P: SharedPointerKind,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T, P, PO> PartialOrd<List<T, PO>> for List<T, P>
impl<T, P, PO> PartialOrd<List<T, PO>> for List<T, P>
Source§impl<T, P> Serialize for List<T, P>where
T: Serialize,
P: SharedPointerKind,
impl<T, P> Serialize for List<T, P>where
T: Serialize,
P: SharedPointerKind,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T, P> Eq for List<T, P>where
T: Eq,
P: SharedPointerKind,
Auto Trait Implementations§
impl<T, P> Freeze for List<T, P>where
P: Freeze,
impl<T, P> RefUnwindSafe for List<T, P>where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for List<T, P>
impl<T, P> Sync for List<T, P>
impl<T, P> Unpin for List<T, P>
impl<T, P> UnwindSafe for List<T, P>where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more