[][src]Trait sdset::Collection

pub trait Collection<T> {
    fn push(&mut self, elem: T);
fn extend_from_slice(&mut self, elems: &[T])
    where
        T: Clone
;
fn extend<I>(&mut self, elems: I)
    where
        I: IntoIterator<Item = T>
; fn reserve(&mut self, _size: usize) { ... } }

This trait is meant to abstract any kind of collection (i.e. Vec, HashSet).

This is particularly helpful when you want particular behavior when inserting elements, the Counter struct is a good example of a custom implementation of the Collection trait, it is used to only count the number of elements of a set operation.

Required methods

fn push(&mut self, elem: T)

Insert one element into the collection.

fn extend_from_slice(&mut self, elems: &[T]) where
    T: Clone

Extend the collection by cloning the elements.

fn extend<I>(&mut self, elems: I) where
    I: IntoIterator<Item = T>, 

Extend the collection by inserting the elements from the given Iterator.

Loading content...

Provided methods

fn reserve(&mut self, _size: usize)

Reserve enough space in the collection for size elements.

Loading content...

Implementations on Foreign Types

impl<T> Collection<T> for Vec<T>[src]

impl<T: Hash + Eq> Collection<T> for HashSet<T>[src]

impl<T: Ord> Collection<T> for BTreeSet<T>[src]

Loading content...

Implementors

impl<T> Collection<T> for Counter[src]

Loading content...