[−][src]Struct tinyvec::ArraySet
An array-backed set
This set supports O(n) operations and has a fixed size, thus may fail to
insert items. The potential advantage is a really small size.
The set is backed by an array of type A and indexed by type L.
The item type must support Default.
Due to restrictions, L may be only u8 or u16.
Implementations
impl<A: Array + Default, L: From<u8>> ArraySet<A, L>[src]
impl<A: Array, L: Copy + Into<usize>> ArraySet<A, L>[src]
pub fn from(arr: A, len: L) -> Self[src]
Constructs a new set from given inputs
Panics if len> arr.len().
impl<A: Array, L> ArraySet<A, L> where
L: Copy + PartialEq + From<u8> + Into<usize>, [src]
L: Copy + PartialEq + From<u8> + Into<usize>,
pub fn capacity(&self) -> usize[src]
Returns the fixed capacity of the set
pub fn len(&self) -> usize[src]
Returns the number of elements in the set
pub fn is_empty(&self) -> bool[src]
Returns true when the set contains no elements
pub fn clear(&mut self)[src]
Removes all elements
pub fn iter(&self) -> Iter<A::Item>ⓘ[src]
Iterate over all contents
impl<A: Array, L> ArraySet<A, L> where
L: Copy + PartialOrd + AddAssign + SubAssign + From<u8> + Into<usize>, [src]
L: Copy + PartialOrd + AddAssign + SubAssign + From<u8> + Into<usize>,
pub fn contains<Q: Eq + ?Sized>(&self, elt: &Q) -> bool where
A::Item: Borrow<Q>, [src]
A::Item: Borrow<Q>,
Check whether the set contains elt
pub fn get<Q: Eq + ?Sized>(&self, elt: &Q) -> Option<&A::Item> where
A::Item: Borrow<Q>, [src]
A::Item: Borrow<Q>,
Get a reference to a contained item matching elt
pub fn remove<Q: Eq + ?Sized>(&mut self, elt: &Q) -> Option<A::Item> where
A::Item: Borrow<Q>, [src]
A::Item: Borrow<Q>,
Remove an item matching elt, if any
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&A::Item) -> bool, [src]
F: FnMut(&A::Item) -> bool,
Remove any items for which f(item) == false
impl<A: Array, L> ArraySet<A, L> where
A::Item: Eq,
L: Copy + PartialOrd + AddAssign + SubAssign + From<u8> + Into<usize>, [src]
A::Item: Eq,
L: Copy + PartialOrd + AddAssign + SubAssign + From<u8> + Into<usize>,
pub fn insert(&mut self, elt: A::Item) -> Result<bool, InsertError>[src]
Insert an item
Due to the fixed size of the backing array, insertion may fail.
pub fn replace(&mut self, elt: A::Item) -> Result<Option<A::Item>, InsertError>[src]
Replace an item matching elt with elt, or insert elt
Returns the replaced item, if any. Fails when there is no matching item and the backing array is full, preventing insertion.
Trait Implementations
impl<A: Clone + Array, L: Clone> Clone for ArraySet<A, L>[src]
fn clone(&self) -> ArraySet<A, L>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<A: Debug + Array, L: Debug> Debug for ArraySet<A, L>[src]
impl<A: Default + Array, L: Default> Default for ArraySet<A, L>[src]
Auto Trait Implementations
impl<A, L> Send for ArraySet<A, L> where
A: Send,
L: Send,
A: Send,
L: Send,
impl<A, L> Sync for ArraySet<A, L> where
A: Sync,
L: Sync,
A: Sync,
L: Sync,
impl<A, L> Unpin for ArraySet<A, L> where
A: Unpin,
L: Unpin,
A: Unpin,
L: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,