Trait BatchContainer

Source
pub trait BatchContainer: Default + 'static {
    type PushItem;
    type ReadItem<'a>: Copy + MyTrait<'a, Owned = Self::PushItem> + for<'b> PartialOrd<Self::ReadItem<'b>>;

    // Required methods
    fn push(&mut self, item: Self::PushItem);
    fn copy_push(&mut self, item: &Self::PushItem);
    fn copy(&mut self, item: Self::ReadItem<'_>);
    fn copy_slice(&mut self, slice: &[Self::PushItem]);
    fn copy_range(&mut self, other: &Self, start: usize, end: usize);
    fn with_capacity(size: usize) -> Self;
    fn reserve(&mut self, additional: usize);
    fn merge_capacity(cont1: &Self, cont2: &Self) -> Self;
    fn index(&self, index: usize) -> Self::ReadItem<'_>;
    fn len(&self) -> usize;

    // Provided methods
    fn last(&self) -> Option<Self::ReadItem<'_>> { ... }
    fn advance<F: for<'a> Fn(Self::ReadItem<'a>) -> bool>(
        &self,
        start: usize,
        end: usize,
        function: F,
    ) -> usize { ... }
}
Expand description

A general-purpose container resembling Vec<T>.

Required Associated Types§

Source

type PushItem

The type of contained item.

The container only supplies references to the item, so it needn’t be sized.

Source

type ReadItem<'a>: Copy + MyTrait<'a, Owned = Self::PushItem> + for<'b> PartialOrd<Self::ReadItem<'b>>

The type that can be read back out of the container.

Required Methods§

Source

fn push(&mut self, item: Self::PushItem)

Inserts an owned item.

Source

fn copy_push(&mut self, item: &Self::PushItem)

Inserts an owned item.

Source

fn copy(&mut self, item: Self::ReadItem<'_>)

Inserts a borrowed item.

Source

fn copy_slice(&mut self, slice: &[Self::PushItem])

Extends from a slice of items.

Source

fn copy_range(&mut self, other: &Self, start: usize, end: usize)

Extends from a range of items in anotherSelf.

Source

fn with_capacity(size: usize) -> Self

Creates a new container with sufficient capacity.

Source

fn reserve(&mut self, additional: usize)

Reserves additional capacity.

Source

fn merge_capacity(cont1: &Self, cont2: &Self) -> Self

Creates a new container with sufficient capacity.

Source

fn index(&self, index: usize) -> Self::ReadItem<'_>

Reference to the element at this position.

Source

fn len(&self) -> usize

Number of contained elements

Provided Methods§

Source

fn last(&self) -> Option<Self::ReadItem<'_>>

Returns the last item if the container is non-empty.

Source

fn advance<F: for<'a> Fn(Self::ReadItem<'a>) -> bool>( &self, start: usize, end: usize, function: F, ) -> usize

Reports the number of elements satisfing the predicate.

This methods relies strongly on the assumption that the predicate stays false once it becomes false, a joint property of the predicate and the layout of Self. This allows advance` to use exponential search to count the number of elements in time logarithmic in the result.

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: Ord + Clone + 'static> BatchContainer for Vec<T>

Source§

type PushItem = T

Source§

type ReadItem<'a> = &'a <Vec<T> as BatchContainer>::PushItem

Source§

fn push(&mut self, item: T)

Source§

fn copy_push(&mut self, item: &T)

Source§

fn copy(&mut self, item: &T)

Source§

fn copy_slice(&mut self, slice: &[T])

Source§

fn copy_range(&mut self, other: &Self, start: usize, end: usize)

Source§

fn with_capacity(size: usize) -> Self

Source§

fn reserve(&mut self, additional: usize)

Source§

fn merge_capacity(cont1: &Self, cont2: &Self) -> Self

Source§

fn index(&self, index: usize) -> Self::ReadItem<'_>

Source§

fn len(&self) -> usize

Source§

impl<T: Ord + Columnation + ToOwned<Owned = T> + 'static> BatchContainer for TimelyStack<T>

Source§

type PushItem = T

Source§

type ReadItem<'a> = &'a <TimelyStack<T> as BatchContainer>::PushItem

Source§

fn push(&mut self, item: Self::PushItem)

Source§

fn copy_push(&mut self, item: &Self::PushItem)

Source§

fn copy(&mut self, item: &T)

Source§

fn copy_slice(&mut self, slice: &[Self::PushItem])

Source§

fn copy_range(&mut self, other: &Self, start: usize, end: usize)

Source§

fn with_capacity(size: usize) -> Self

Source§

fn reserve(&mut self, _additional: usize)

Source§

fn merge_capacity(cont1: &Self, cont2: &Self) -> Self

Source§

fn index(&self, index: usize) -> Self::ReadItem<'_>

Source§

fn len(&self) -> usize

Implementors§

Source§

impl<B> BatchContainer for HuffmanContainer<B>
where B: Ord + Clone + Sized + 'static,

Source§

type PushItem = Vec<B>

Source§

type ReadItem<'a> = Wrapped<'a, B>

Source§

impl<B> BatchContainer for SliceContainer2<B>
where B: Ord + Clone + Sized + 'static,

Source§

type PushItem = Vec<B>

Source§

type ReadItem<'a> = Greetings<'a, B>

Source§

impl<B> BatchContainer for SliceContainer<B>
where B: Ord + Clone + Sized + 'static,

Source§

type PushItem = Vec<B>

Source§

type ReadItem<'a> = &'a [B]