[][src]Struct tinyvec::ArraySet

pub struct ArraySet<A: Array, L> { /* fields omitted */ }

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]

pub fn new() -> Self[src]

Constructs a new, empty, set

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]

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>

Important traits for Iter<'a, T>

impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
[src]

Iterate over all contents

impl<A: Array, L> ArraySet<A, L> where
    L: Copy + PartialOrd + AddAssign + SubAssign + From<u8> + Into<usize>, 
[src]

pub fn contains<Q: Eq + ?Sized>(&self, elt: &Q) -> bool where
    A::Item: Borrow<Q>, 
[src]

Check whether the set contains elt

pub fn get<Q: Eq + ?Sized>(&self, elt: &Q) -> Option<&A::Item> where
    A::Item: Borrow<Q>, 
[src]

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]

Remove an item matching elt, if any

pub fn retain<F>(&mut self, f: F) where
    F: FnMut(&A::Item) -> bool, 
[src]

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]

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]

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

impl<A, L> Sync for ArraySet<A, L> where
    A: Sync,
    L: Sync

impl<A, L> Unpin for ArraySet<A, L> where
    A: Unpin,
    L: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.