pub struct Palette<T> { /* private fields */ }
Expand description
A palette is a vector with limited capacity that allows searching indices of elements.
Implementations§
Source§impl<T> Palette<T>
impl<T> Palette<T>
Sourcepub fn with_defaults<I>(defaults: I, capacity: usize) -> Selfwhere
I: IntoIterator<Item = T>,
pub fn with_defaults<I>(defaults: I, capacity: usize) -> Selfwhere
I: IntoIterator<Item = T>,
Create a new palette of the specified capacity and fill it with the given iterator.
At most capacity
elements are took from the iterator.
Sourcepub fn with_default(default: T, capacity: usize) -> Self
pub fn with_default(default: T, capacity: usize) -> Self
Create a new palette with a default element into it and with the specified capacity.
pub fn from_raw(items: Vec<T>, capacity: usize) -> Self
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn clear(&mut self)
pub fn ensure_index(&mut self, target_item: T) -> Option<usize>
pub fn insert_index(&mut self, target_item: T) -> Option<usize>
pub fn search_index(&self, target_item: T) -> Option<usize>
pub fn get_item(&self, index: usize) -> Option<T>
pub fn iter(&self) -> impl Iterator<Item = T> + '_
Auto Trait Implementations§
impl<T> Freeze for Palette<T>
impl<T> RefUnwindSafe for Palette<T>where
T: RefUnwindSafe,
impl<T> Send for Palette<T>where
T: Send,
impl<T> Sync for Palette<T>where
T: Sync,
impl<T> Unpin for Palette<T>where
T: Unpin,
impl<T> UnwindSafe for Palette<T>where
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