Trait timely_container::Container

source ·
pub trait Container:
    Default
    + Clone
    + 'static {
    type ItemRef<'a>
       where Self: 'a;
    type Item<'a>
       where Self: 'a;
    type Iter<'a>: Iterator<Item = Self::ItemRef<'a>>;
    type DrainIter<'a>: Iterator<Item = Self::Item<'a>>;

    // Required methods
    fn len(&self) -> usize;
    fn clear(&mut self);
    fn iter(&self) -> Self::Iter<'_>;
    fn drain(&mut self) -> Self::DrainIter<'_>;

    // Provided methods
    fn push<T>(&mut self, item: T)
       where Self: PushInto<T> { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

A container transferring data through dataflow edges

A container stores a number of elements and thus is able to describe it length (len()) and whether it is empty (is_empty()). It supports removing all elements (clear).

A container must implement default. The default implementation is not required to allocate memory for variable-length components.

We require the container to be cloneable to enable efficient copies when providing references of containers to operators. Care must be taken that the type’s clone_from implementation is efficient (which is not necessarily the case when deriving Clone.) TODO: Don’t require Container: Clone

Required Associated Types§

source

type ItemRef<'a> where Self: 'a

The type of elements when reading non-destructively from the container.

source

type Item<'a> where Self: 'a

The type of elements when draining the container.

source

type Iter<'a>: Iterator<Item = Self::ItemRef<'a>>

Iterator type when reading from the container.

source

type DrainIter<'a>: Iterator<Item = Self::Item<'a>>

Iterator type when draining the container.

Required Methods§

source

fn len(&self) -> usize

The number of elements in this container

The length of a container must be consistent between sending and receiving it. When exchanging a container and partitioning it into pieces, the sum of the length of all pieces must be equal to the length of the original container. When combining containers, the length of the result must be the sum of the individual parts.

source

fn clear(&mut self)

Remove all contents from self while retaining allocated memory. After calling clear, is_empty must return true and len 0.

source

fn iter(&self) -> Self::Iter<'_>

Returns an iterator that reads the contents of this container.

source

fn drain(&mut self) -> Self::DrainIter<'_>

Returns an iterator that drains the contents of this container. Drain leaves the container in an undefined state.

Provided Methods§

source

fn push<T>(&mut self, item: T)
where Self: PushInto<T>,

Push item into self

source

fn is_empty(&self) -> bool

Determine if the container contains any elements, corresponding to len() == 0.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: Clone + 'static> Container for Vec<T>

§

type ItemRef<'a> = &'a T where T: 'a

§

type Item<'a> = T where T: 'a

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn clear(&mut self)

§

type Iter<'a> = Iter<'a, T>

source§

fn iter(&self) -> Self::Iter<'_>

§

type DrainIter<'a> = Drain<'a, T>

source§

fn drain(&mut self) -> Self::DrainIter<'_>

source§

impl<T: Container> Container for Rc<T>

§

type ItemRef<'a> = <T as Container>::ItemRef<'a> where Self: 'a

§

type Item<'a> = <T as Container>::ItemRef<'a> where Self: 'a

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn clear(&mut self)

§

type Iter<'a> = <T as Container>::Iter<'a>

source§

fn iter(&self) -> Self::Iter<'_>

§

type DrainIter<'a> = <T as Container>::Iter<'a>

source§

fn drain(&mut self) -> Self::DrainIter<'_>

source§

impl<T: Container> Container for Arc<T>

§

type ItemRef<'a> = <T as Container>::ItemRef<'a> where Self: 'a

§

type Item<'a> = <T as Container>::ItemRef<'a> where Self: 'a

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn clear(&mut self)

§

type Iter<'a> = <T as Container>::Iter<'a>

source§

fn iter(&self) -> Self::Iter<'_>

§

type DrainIter<'a> = <T as Container>::Iter<'a>

source§

fn drain(&mut self) -> Self::DrainIter<'_>

Implementors§

source§

impl<R: Region + Clone + 'static> Container for FlatStack<R>

§

type ItemRef<'a> = <R as Region>::ReadItem<'a> where Self: 'a

§

type Item<'a> = <R as Region>::ReadItem<'a> where Self: 'a

§

type Iter<'a> = <&'a FlatStack<R> as IntoIterator>::IntoIter

§

type DrainIter<'a> = <FlatStack<R> as Container>::Iter<'a>

source§

impl<T: Columnation + 'static> Container for TimelyStack<T>

§

type ItemRef<'a> = &'a T where Self: 'a

§

type Item<'a> = &'a T where Self: 'a

§

type Iter<'a> = Iter<'a, T>

§

type DrainIter<'a> = Iter<'a, T>