SliceMap

Struct SliceMap 

Source
pub struct SliceMap<K, V, S>
where K: Key, S: SliceStorage<K, Range<u32>>,
{ /* private fields */ }
Expand description

This generic SliceMap needs to be provided a Key type, a Value type and a Storage type. Use SlotSliceMap and SecSliceMap for storage using SlotMap and SecondarySlotMap, respectively.

Implementations§

Source§

impl<K, V, S> SliceMap<K, V, S>
where K: Key, S: SliceStorage<K, Range<u32>> + Default,

Source

pub fn new() -> Self

Returns a new SliceMap containing the provided items object.

Source

pub fn with_capacity(cap: usize) -> Self

Returns a new SliceMap with the specified initial capacity.

Source

pub fn clear(&mut self)

Clears the SliceMap.

Source

pub fn items(&self) -> &[V]

Returns a slice with all items in all slices.

Source

pub fn items_len(&self) -> usize

How many items are contained in all slices.

Source

pub fn is_empty(&self) -> bool

True if no items

Source

pub fn slices_len(&self) -> usize

How many slices are contained in the SliceMap.

Source

pub fn get_slice(&self, key: K) -> Option<&[V]>

Returns a slice with the desired range

Source

pub fn iter_slices(&self) -> SliceIter<'_, K, V, S>

Returns an iterator for slices of items.

Source

pub fn iter_keys_and_slices(&self) -> KeySliceIter<'_, K, V, S>

Returns an iterator for slices of items along with their keys.

Source

pub fn iter_items(&self) -> impl Iterator<Item = &V>

Returns an iterator for each individual item.

Source

pub fn remove_slice(&mut self, key: K) -> Option<Range<u32>>

Removes a slice by key. Warning: Will cause all items to “shift” to occupy the removed space, and all slices will be updated with the new indices.

Source§

impl<K, V> SliceMap<K, V, SlotMap<K, Range<u32>>>
where K: Key, V: Clone,

Source

pub fn add_items<ITEMS>(&mut self, new_items: ITEMS) -> K
where ITEMS: AsRef<[V]>,

Creates a new slice with all items from an iterator of owned or borrowed V items. Accepts arrays, slices, or any type that implements AsRef<[V]>. Will panic if the capacity of u32::MAX items is reached.

Source§

impl<K, V> SliceMap<K, V, SecondaryMap<K, Range<u32>>>
where K: Key, V: Clone,

Source

pub fn add_items<ITEMS>(&mut self, key: K, new_items: ITEMS)
where ITEMS: AsRef<[V]>,

Creates a new slice with all items from an iterable of owned or borrowed V items. Accepts arrays, slices, or any other AsRef<[V]> type. Will panic if the capacity of u32::MAX items is reached.

Source§

impl<K, V> SliceMap<K, V, SparseSecondaryMap<K, Range<u32>>>
where K: Key, V: Clone,

Source

pub fn add_items<ITEMS>(&mut self, key: K, new_items: ITEMS)
where ITEMS: AsRef<[V]>,

Creates a new slice with all items from an iterable of owned or borrowed V items. Accepts arrays, slices, or any other AsRef<[V]> type. Will panic if the capacity of u32::MAX items is reached.

Trait Implementations§

Source§

impl<K, V: Clone, S> Clone for SliceMap<K, V, S>
where K: Key + Clone, S: SliceStorage<K, Range<u32>> + Clone,

Source§

fn clone(&self) -> SliceMap<K, V, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<K, V: Debug, S> Debug for SliceMap<K, V, S>
where K: Key + Debug, S: SliceStorage<K, Range<u32>> + Debug,

Source§

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

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

impl<K, V: Default, S> Default for SliceMap<K, V, S>
where K: Key + Default, S: SliceStorage<K, Range<u32>> + Default,

Source§

fn default() -> SliceMap<K, V, S>

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

Auto Trait Implementations§

§

impl<K, V, S> Freeze for SliceMap<K, V, S>
where S: Freeze,

§

impl<K, V, S> RefUnwindSafe for SliceMap<K, V, S>

§

impl<K, V, S> Send for SliceMap<K, V, S>
where S: Send, K: Send, V: Send,

§

impl<K, V, S> Sync for SliceMap<K, V, S>
where S: Sync, K: Sync, V: Sync,

§

impl<K, V, S> Unpin for SliceMap<K, V, S>
where S: Unpin, K: Unpin, V: Unpin,

§

impl<K, V, S> UnwindSafe for SliceMap<K, V, S>
where S: UnwindSafe, K: UnwindSafe, V: 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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.