Struct flatcontainer::FlatStack

source ·
pub struct FlatStack<R: Region> { /* private fields */ }
Expand description

A container for indices into a region.

Implementations§

source§

impl<R: Region> FlatStack<R>

source

pub fn default_impl<T: RegionPreference<Region = R>>() -> Self

Default implementation based on the preference of type T.

source

pub fn with_capacity(capacity: usize) -> Self

Returns a flat stack that can absorb capacity indices without reallocation.

Prefer Self::merge_capacity over this function to also pre-size the regions.

source

pub fn merge_capacity<'a, I: Iterator<Item = &'a Self> + Clone + 'a>( stacks: I, ) -> Self
where R: 'a,

Returns a flat stack that can absorb the contents of iter without reallocation.

source

pub fn copy<T>(&mut self, item: T)
where R: Push<T>,

Appends the element to the back of the stack.

source

pub fn get(&self, offset: usize) -> R::ReadItem<'_>

Returns the element at the offset position.

source

pub fn len(&self) -> usize

Returns the number of indices in the stack.

source

pub fn is_empty(&self) -> bool

Returns true if the stack contains no elements.

source

pub fn capacity(&self) -> usize

Returns the total number of indices the stack can hold without reallocation.

source

pub fn reserve(&mut self, additional: usize)

Reserves space to hold additional indices.

source

pub fn clear(&mut self)

Remove all elements while possibly retaining allocations.

source

pub fn reserve_items<T>(&mut self, items: impl Iterator<Item = T> + Clone)
where R: ReserveItems<T>,

Reserve space for the items returned by the iterator.

source

pub fn reserve_regions<'a>( &mut self, regions: impl Iterator<Item = &'a R> + Clone, )
where R: 'a,

Reserve space for the regions returned by the iterator.

source

pub fn iter(&self) -> Iter<'_, R>

Iterate the items in this stack.

source

pub fn heap_size<F: FnMut(usize, usize)>(&self, callback: F)

Heap size, size - capacity

Trait Implementations§

source§

impl<R: Region + Clone> Clone for FlatStack<R>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Region> Debug for FlatStack<R>
where for<'a> R::ReadItem<'a>: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: Region> Default for FlatStack<R>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, R> Deserialize<'de> for FlatStack<R>
where R: Serialize + for<'a> Deserialize<'a> + Region, R::Index: Serialize + for<'a> Deserialize<'a>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T, R: Region + Push<T>> Extend<T> for FlatStack<R>

source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<R: Region + Push<T>, T> FromIterator<T> for FlatStack<R>

source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<'a, R: Region> IntoIterator for &'a FlatStack<R>

§

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

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, R>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<R> Serialize for FlatStack<R>
where R: Serialize + for<'a> Deserialize<'a> + Region, R::Index: Serialize + for<'a> Deserialize<'a>,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<R> Freeze for FlatStack<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for FlatStack<R>

§

impl<R> Send for FlatStack<R>
where R: Send, <R as Region>::Index: Send,

§

impl<R> Sync for FlatStack<R>
where R: Sync, <R as Region>::Index: Sync,

§

impl<R> Unpin for FlatStack<R>
where R: Unpin, <R as Region>::Index: Unpin,

§

impl<R> UnwindSafe for FlatStack<R>
where R: UnwindSafe, <R as Region>::Index: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,