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

    // Required methods
    fn copy(&mut self, item: Self::ReadItem<'_>);
    fn with_capacity(size: usize) -> Self;
    fn merge_capacity(cont1: &Self, cont2: &Self) -> Self;
    fn index(&self, index: usize) -> Self::ReadItem<'_>;
    fn len(&self) -> usize;

    // Provided methods
    fn push(&mut self, item: Self::PushItem) { ... }
    fn copy_push(&mut self, item: &Self::PushItem) { ... }
    fn copy_range(&mut self, other: &Self, start: usize, end: usize) { ... }
    fn last(&self) -> Option<Self::ReadItem<'_>> { ... }
    fn is_empty(&self) -> bool { ... }
    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 copy(&mut self, item: Self::ReadItem<'_>)

Inserts a borrowed item.

source

fn with_capacity(size: usize) -> Self

Creates a new container with sufficient 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 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_range(&mut self, other: &Self, start: usize, end: usize)

Extends from a range of items in anotherSelf.

source

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

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

source

fn is_empty(&self) -> bool

Indicates if the length is zero.

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

§

type PushItem = T

§

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

source§

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

source§

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

source§

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

source§

fn with_capacity(size: usize) -> Self

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

§

type PushItem = T

§

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_range(&mut self, other: &Self, start: usize, end: usize)

source§

fn with_capacity(size: usize) -> Self

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 BatchContainer for OffsetList

source§

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

§

type PushItem = Vec<B>

§

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

source§

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

§

type PushItem = Vec<B>

§

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

source§

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

§

type PushItem = Vec<B>

§

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

source§

impl<C> BatchContainer for OptionContainer<C>