timely_container

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn clear(&mut self)

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn clear(&mut self)

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn clear(&mut self)

Source§

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

Source§

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

Implementors§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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