Trait BatchContainer

Source
pub trait BatchContainer: 'static {
    type Owned: Clone + Ord;
    type ReadItem<'a>: Copy + Ord;

Show 14 methods // Required methods fn into_owned<'a>(item: Self::ReadItem<'a>) -> Self::Owned; fn push_ref(&mut self, item: Self::ReadItem<'_>); fn push_own(&mut self, item: &Self::Owned); fn clear(&mut self); fn with_capacity(size: usize) -> Self; fn merge_capacity(cont1: &Self, cont2: &Self) -> Self; fn reborrow<'b, 'a: 'b>(item: Self::ReadItem<'a>) -> Self::ReadItem<'b>; fn index(&self, index: usize) -> Self::ReadItem<'_>; fn len(&self) -> usize; // Provided methods fn clone_onto<'a>(item: Self::ReadItem<'a>, other: &mut Self::Owned) { ... } fn get(&self, index: usize) -> Option<Self::ReadItem<'_>> { ... } 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 Owned: Clone + Ord

An owned instance of Self::ReadItem<'_>.

Source

type ReadItem<'a>: Copy + Ord

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

Required Methods§

Source

fn into_owned<'a>(item: Self::ReadItem<'a>) -> Self::Owned

Conversion from an instance of this type to the owned type.

Source

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

Push an item into this container

Source

fn push_own(&mut self, item: &Self::Owned)

Push an item into this container

Source

fn clear(&mut self)

Clears the container. May not release resources.

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 reborrow<'b, 'a: 'b>(item: Self::ReadItem<'a>) -> Self::ReadItem<'b>

Converts a read item into one with a narrower lifetime.

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 clone_onto<'a>(item: Self::ReadItem<'a>, other: &mut Self::Owned)

Clones self onto an existing instance of the owned type.

Source

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

Reference to the element at this position, if it exists.

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 satisfying 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 Owned = T

Source§

type ReadItem<'a> = &'a T

Source§

fn into_owned<'a>(item: Self::ReadItem<'a>) -> Self::Owned

Source§

fn clone_onto<'a>(item: Self::ReadItem<'a>, other: &mut Self::Owned)

Source§

fn reborrow<'b, 'a: 'b>(item: Self::ReadItem<'a>) -> Self::ReadItem<'b>

Source§

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

Source§

fn push_own(&mut self, item: &Self::Owned)

Source§

fn clear(&mut self)

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 get(&self, index: usize) -> Option<Self::ReadItem<'_>>

Source§

fn len(&self) -> usize

Implementors§

Source§

impl BatchContainer for OffsetList

Source§

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

Source§

type Owned = Vec<B>

Source§

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

Source§

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

Source§

type Owned = Vec<B>

Source§

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

Source§

impl<T: Clone + Ord + Columnation + 'static> BatchContainer for TimelyStack<T>