Struct alot::ordered::OrderedLots
source · pub struct OrderedLots<T> { /* private fields */ }
Expand description
Implementations§
source§impl<T> OrderedLots<T>
impl<T> OrderedLots<T>
sourcepub fn with_capacity(initial_capacity: usize) -> Self
pub fn with_capacity(initial_capacity: usize) -> Self
Returns an empty collection that can hold initial_capacity
values
without reallocation.
sourcepub fn push(&mut self, value: T) -> LotId
pub fn push(&mut self, value: T) -> LotId
Adds value
to the end of the collection, returning the value’s unique
LotId
.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the last element of the collection, if one is present.
sourcepub fn pop_entry(&mut self) -> Option<(LotId, T)>
pub fn pop_entry(&mut self) -> Option<(LotId, T)>
Removes the last element of the collection, if one is present.
sourcepub fn insert(&mut self, offset: usize, value: T) -> LotId
pub fn insert(&mut self, offset: usize, value: T) -> LotId
Inserts value
at offset
inside of the collection.
Panics
This funciton panics if offset is greater than the length of the collection.
sourcepub fn remove_by_index(&mut self, index: usize) -> Option<(LotId, T)>
pub fn remove_by_index(&mut self, index: usize) -> Option<(LotId, T)>
Removes the value at index
, returning the LotId
and value if
found.
sourcepub fn sort(&mut self)where
T: Ord,
pub fn sort(&mut self)where
T: Ord,
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort()
for more information.
sourcepub fn sort_by<F: Fn(&T, &T) -> Ordering>(&mut self, comparison: F)
pub fn sort_by<F: Fn(&T, &T) -> Ordering>(&mut self, comparison: F)
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort_by()
for more information.
sourcepub fn sort_by_key<K, F>(&mut self, f: F)
pub fn sort_by_key<K, F>(&mut self, f: F)
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort_by_key()
for more information.
sourcepub fn sort_by_cached_key<K, F>(&mut self, f: F)
pub fn sort_by_cached_key<K, F>(&mut self, f: F)
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort_by_cached_key()
for more information.
sourcepub fn sort_unstable(&mut self)where
T: Ord,
pub fn sort_unstable(&mut self)where
T: Ord,
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort_unstable()
for more information.
sourcepub fn sort_unstable_by<F: Fn(&T, &T) -> Ordering>(&mut self, comparison: F)
pub fn sort_unstable_by<F: Fn(&T, &T) -> Ordering>(&mut self, comparison: F)
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort_unstable_by()
for more
information.
sourcepub fn sort_unstable_by_key<K, F>(&mut self, f: F)
pub fn sort_unstable_by_key<K, F>(&mut self, f: F)
Orders the elements in this collection leveraging the standard library’s
sorting implementation. See slice::sort_unstable_by_key()
for more
information.
sourcepub fn get_by_index(&self, index: usize) -> Option<&T>
pub fn get_by_index(&self, index: usize) -> Option<&T>
Looks up a value by index. If index
is greater than or equal to the
collections length, None
will be returned.
sourcepub fn get_mut_by_index(&mut self, index: usize) -> Option<&mut T>
pub fn get_mut_by_index(&mut self, index: usize) -> Option<&mut T>
Looks up a mutable reference to a value by index. If index
is greater
than or equal to the collections length, None
will be returned.
sourcepub fn index_of_id(&self, id: LotId) -> Option<usize>
pub fn index_of_id(&self, id: LotId) -> Option<usize>
Returns the index of id
, or None if the id is not contained in this
collection.
sourcepub fn id(&self, index: usize) -> Option<LotId>
pub fn id(&self, index: usize) -> Option<LotId>
Returns the id of the entry at index
, or None if index
is outside of
the bounds of this collection.
sourcepub fn key(&self, index: usize) -> Option<LotId>
pub fn key(&self, index: usize) -> Option<LotId>
Returns the LotId
associated with a given index. Returns None
if
index
is greater than or equal to the collections length.
sourcepub fn drain(&mut self) -> Drain<'_, T, DrainAll> ⓘ
pub fn drain(&mut self) -> Drain<'_, T, DrainAll> ⓘ
Returns an iterator that returns all the contained values in this collection as they’re removed from the collection.
Dropping the iterator will still result in the elements being removed.
sourcepub fn drain_filter<Filter>(&mut self, filter: Filter) -> Drain<'_, T, Filter> ⓘ
pub fn drain_filter<Filter>(&mut self, filter: Filter) -> Drain<'_, T, Filter> ⓘ
Returns an iterator that invokes filter
for each item in the
collection. If filter
returns true for that value, it will be removed
and returned from the iterator. When false is returned, the value is
kept in the collection.
Dropping the iterator will still result in the filtered elements being removed.
sourcepub fn entries(&self) -> EntryIter<'_, T> ⓘ
pub fn entries(&self) -> EntryIter<'_, T> ⓘ
Returns an Iterator<Item = (LotId, &T)>
for all contained values.
sourcepub fn first(&self) -> Option<&T>
pub fn first(&self) -> Option<&T>
Returns the first entry in this collection, or None if the collection is empty.
sourcepub fn first_mut(&mut self) -> Option<&mut T>
pub fn first_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the first entry in this collection, or None if the collection is empty.
sourcepub fn last(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
Returns the last entry in this collection, or None if the collection is empty.
Trait Implementations§
source§impl<T: Clone> Clone for OrderedLots<T>
impl<T: Clone> Clone for OrderedLots<T>
source§fn clone(&self) -> OrderedLots<T>
fn clone(&self) -> OrderedLots<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more