pub struct SkipList<T> { /* private fields */ }Implementations§
Source§impl<T: Ord> SkipList<T>
impl<T: Ord> SkipList<T>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Wrapper for len() that returns a Boolean
indicating whether the list is empty.
Sourcepub fn get<Q>(&self, key: &Q) -> Option<&T>
pub fn get<Q>(&self, key: &Q) -> Option<&T>
Returns the a reference to the entry associated with the search key
if it exists in the list, otherwise returns None to indicate
that the key is not in the list.
Represents Pugh’s canonical Search operation as described in the
original paper.
Sourcepub fn contains<Q>(&self, key: &Q) -> bool
pub fn contains<Q>(&self, key: &Q) -> bool
Returns a Boolean indicating whether the supplied search key exists in the list.
Wrapper for the public get() operation, which itself wraps
the private skip_search() operation.
Sourcepub fn insert(&mut self, entry: T)
pub fn insert(&mut self, entry: T)
Inserts a new entry into the skip list.
Allows duplicates, where ordering is determined by insertion order such that the most recent duplicates come before older entries.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<T>
pub fn remove<Q>(&mut self, key: &Q) -> Option<T>
Removes and returns the value for a given key, if it exists in the list. Returns None if the key does not exist in the list.
This function does not technically adhere to Pugh’s original removal algorithm. It uses Vec::swap_remove for simplified backing list compaction with the side effect of re-ordering remaining elements. The resultant removal time is therefore O(n * height), which is O(n * log(n)) expected, and O(n^2) worst case.