pub struct ItemList<T: A2lObjectName> { /* private fields */ }Expand description
A list of named a2l items
An ItemList is an ordered collection of items, which additionally allows for fast access to items by their name.
Implementations§
Source§impl<T: A2lObjectName> ItemList<T>
impl<T: A2lObjectName> ItemList<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
create a new ItemList with a specified initial capacity
Sourcepub fn push_unique(&mut self, value: T)
pub fn push_unique(&mut self, value: T)
push an item into the ItemList, replacing any existing item with the same name
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut T>
pub fn get_mut(&mut self, key: &str) -> Option<&mut T>
get a mutable reference to an item by key
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Checks if the ItemList contains an item with the given key
Sourcepub fn swap_remove(&mut self, key: &str) -> Option<T>
pub fn swap_remove(&mut self, key: &str) -> Option<T>
remove an item from the ItemList by key and return it
Sourcepub fn swap_remove_idx(&mut self, index: usize) -> Option<T>
pub fn swap_remove_idx(&mut self, index: usize) -> Option<T>
remove an item from the ItemList by index and return it
Sourcepub fn iter(&self) -> impl Iterator<Item = &T>
pub fn iter(&self) -> impl Iterator<Item = &T>
Returns an iterator over references to the items in the ItemList
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
Returns an iterator over mutable references to the items in the ItemList
Sourcepub fn keys(&self) -> impl Iterator<Item = &String>
pub fn keys(&self) -> impl Iterator<Item = &String>
Returns an iterator over the keys in the ItemList
Sourcepub fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
pub fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
extend the ItemList from an iterator
Sourcepub fn retain<F>(&mut self, keep: F)
pub fn retain<F>(&mut self, keep: F)
Selectively remove or retain items from the ItemList based on a predicate function
pub fn sort_by<F>(&mut self, cmp: F)
Source§impl<T: A2lObjectName + A2lObjectNameSetter> ItemList<T>
impl<T: A2lObjectName + A2lObjectNameSetter> ItemList<T>
Sourcepub fn rename_item(&mut self, item_idx: usize, new_name: &str)
pub fn rename_item(&mut self, item_idx: usize, new_name: &str)
Set the name of an item in the ItemList