Struct Slice

Source
pub struct Slice<V, S = EntityHash>(/* private fields */);
Expand description

A dynamically-sized slice of key-value pairs in an EntityIndexMap.

Equivalent to an indexmap::map::Slice<V> whose source IndexMap uses EntityHash.

Implementations§

Source§

impl<V> Slice<V>

Source

pub const fn new<'a>() -> &'a Slice<V>

Returns an empty slice.

Equivalent to map::Slice::new.

Source

pub fn new_mut<'a>() -> &'a mut Slice<V>

Returns an empty mutable slice.

Equivalent to map::Slice::new_mut.

Source

pub const unsafe fn from_slice_unchecked(slice: &Slice<Entity, V>) -> &Slice<V>

Constructs a entity::index_map::Slice from a indexmap::map::Slice unsafely.

§Safety

slice must stem from an IndexMap using EntityHash.

Source

pub const unsafe fn from_slice_unchecked_mut( slice: &mut Slice<Entity, V>, ) -> &mut Slice<V>

Constructs a entity::index_map::Slice from a indexmap::map::Slice unsafely.

§Safety

slice must stem from an IndexMap using EntityHash.

Source

pub const fn as_inner(&self) -> &Slice<Entity, V>

Casts self to the inner slice.

Source

pub unsafe fn from_boxed_slice_unchecked( slice: Box<Slice<Entity, V>>, ) -> Box<Slice<V>>

Constructs a boxed entity::index_map::Slice from a boxed indexmap::map::Slice unsafely.

§Safety

slice must stem from an IndexMap using EntityHash.

Source

pub fn as_boxed_inner(self: &Box<Slice<V>>) -> &Box<Slice<Entity, V>>

Casts a reference to self to the inner slice.

Source

pub fn into_boxed_inner(self: Box<Slice<V>>) -> Box<Slice<Entity, V>>

Casts self to the inner slice.

Source

pub fn get_index_mut(&mut self, index: usize) -> Option<(&Entity, &mut V)>

Get a key-value pair by index, with mutable access to the value.

Equivalent to map::Slice::get_index_mut.

Source

pub fn get_range<R>(&self, range: R) -> Option<&Slice<V>>
where R: RangeBounds<usize>,

Returns a slice of key-value pairs in the given range of indices.

Equivalent to map::Slice::get_range.

Source

pub fn get_range_mut<R>(&mut self, range: R) -> Option<&mut Slice<V>>
where R: RangeBounds<usize>,

Returns a mutable slice of key-value pairs in the given range of indices.

Equivalent to map::Slice::get_range_mut.

Source

pub fn first_mut(&mut self) -> Option<(&Entity, &mut V)>

Get the first key-value pair, with mutable access to the value.

Equivalent to map::Slice::first_mut.

Source

pub fn last_mut(&mut self) -> Option<(&Entity, &mut V)>

Get the last key-value pair, with mutable access to the value.

Equivalent to map::Slice::last_mut.

Source

pub fn split_at(&self, index: usize) -> (&Slice<V>, &Slice<V>)

Divides one slice into two at an index.

Equivalent to map::Slice::split_at.

Source

pub fn split_at_mut(&mut self, index: usize) -> (&mut Slice<V>, &mut Slice<V>)

Divides one mutable slice into two at an index.

Equivalent to map::Slice::split_at_mut.

Source

pub fn split_first(&self) -> Option<((&Entity, &V), &Slice<V>)>

Returns the first key-value pair and the rest of the slice, or None if it is empty.

Equivalent to map::Slice::split_first.

Source

pub fn split_first_mut(&mut self) -> Option<((&Entity, &mut V), &mut Slice<V>)>

Returns the first key-value pair and the rest of the slice, with mutable access to the value, or None if it is empty.

Equivalent to map::Slice::split_first_mut.

Source

pub fn split_last(&self) -> Option<((&Entity, &V), &Slice<V>)>

Returns the last key-value pair and the rest of the slice, or None if it is empty.

Equivalent to map::Slice::split_last.

Source

pub fn split_last_mut(&mut self) -> Option<((&Entity, &mut V), &mut Slice<V>)>

Returns the last key-value pair and the rest of the slice, with mutable access to the value, or None if it is empty.

Equivalent to map::Slice::split_last_mut.

Source

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

Return an iterator over the key-value pairs of the map slice.

Equivalent to map::Slice::iter.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, V>

Return an iterator over the key-value pairs of the map slice.

Equivalent to map::Slice::iter_mut.

Source

pub fn keys(&self) -> Keys<'_, V>

Return an iterator over the keys of the map slice.

Equivalent to map::Slice::keys.

Source

pub fn into_keys(self: Box<Slice<V>>) -> IntoKeys<V>

Return an owning iterator over the keys of the map slice.

Equivalent to map::Slice::into_keys.

Source

pub fn values_mut(&mut self) -> ValuesMut<'_, Entity, V>

Return an iterator over mutable references to the the values of the map slice.

Equivalent to map::Slice::values_mut.

Source

pub fn into_values(self: Box<Slice<V>>) -> IntoValues<Entity, V>

Return an owning iterator over the values of the map slice.

Equivalent to map::Slice::into_values.

Methods from Deref<Target = Slice<Entity, V>>§

Source

pub fn len(&self) -> usize

Return the number of key-value pairs in the map slice.

Source

pub fn is_empty(&self) -> bool

Returns true if the map slice contains no elements.

Source

pub fn get_index(&self, index: usize) -> Option<(&K, &V)>

Get a key-value pair by index.

Valid indices are 0 <= index < self.len().

Source

pub fn get_range<R>(&self, range: R) -> Option<&Slice<K, V>>
where R: RangeBounds<usize>,

Returns a slice of key-value pairs in the given range of indices.

Valid indices are 0 <= index < self.len().

Source

pub fn first(&self) -> Option<(&K, &V)>

Get the first key-value pair.

Source

pub fn last(&self) -> Option<(&K, &V)>

Get the last key-value pair.

Source

pub fn split_at(&self, index: usize) -> (&Slice<K, V>, &Slice<K, V>)

Divides one slice into two at an index.

Panics if index > len.

Source

pub fn split_first(&self) -> Option<((&K, &V), &Slice<K, V>)>

Returns the first key-value pair and the rest of the slice, or None if it is empty.

Source

pub fn split_last(&self) -> Option<((&K, &V), &Slice<K, V>)>

Returns the last key-value pair and the rest of the slice, or None if it is empty.

Source

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

Return an iterator over the key-value pairs of the map slice.

Source

pub fn keys(&self) -> Keys<'_, K, V>

Return an iterator over the keys of the map slice.

Source

pub fn values(&self) -> Values<'_, K, V>

Return an iterator over the values of the map slice.

Source

pub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>
where K: Ord,

Search over a sorted map for a key.

Returns the position where that key is present, or the position where it can be inserted to maintain the sort. See slice::binary_search for more details.

Computes in O(log(n)) time, which is notably less scalable than looking the key up in the map this is a slice from using IndexMap::get_index_of, but this can also position missing keys.

Source

pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
where F: FnMut(&'a K, &'a V) -> Ordering,

Search over a sorted map with a comparator function.

Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See slice::binary_search_by for more details.

Computes in O(log(n)) time.

Source

pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize>
where F: FnMut(&'a K, &'a V) -> B, B: Ord,

Search over a sorted map with an extraction function.

Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See slice::binary_search_by_key for more details.

Computes in O(log(n)) time.

Source

pub fn partition_point<P>(&self, pred: P) -> usize
where P: FnMut(&K, &V) -> bool,

Returns the index of the partition point of a sorted map according to the given predicate (the index of the first element of the second partition).

See slice::partition_point for more details.

Computes in O(log(n)) time.

Trait Implementations§

Source§

impl<V> Clone for Box<Slice<V>>
where V: Clone,

Source§

fn clone(&self) -> Box<Slice<V>>

Returns a copy 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<V> Debug for Slice<V>
where V: Debug,

Source§

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

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

impl<V> Default for &Slice<V>

Source§

fn default() -> &Slice<V>

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

impl<V> Default for &mut Slice<V>

Source§

fn default() -> &mut Slice<V>

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

impl<V> Default for Box<Slice<V>>

Source§

fn default() -> Box<Slice<V>>

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

impl<V> Deref for Slice<V>

Source§

type Target = Slice<Entity, V>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Slice<V> as Deref>::Target

Dereferences the value.
Source§

impl<V> From<&Slice<V>> for Box<Slice<V>>
where V: Copy,

Source§

fn from(value: &Slice<V>) -> Box<Slice<V>>

Converts to this type from the input type.
Source§

impl<V> Hash for Slice<V>
where V: Hash,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl<V> Index<(Bound<usize>, Bound<usize>)> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: (Bound<usize>, Bound<usize>)) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<Range<usize>> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: Range<usize>) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<RangeFrom<usize>> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: RangeFrom<usize>) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<RangeFull> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: RangeFull) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<RangeInclusive<usize>> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: RangeInclusive<usize>) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<RangeTo<usize>> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: RangeTo<usize>) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<RangeToInclusive<usize>> for Slice<V>

Source§

type Output = Slice<V>

The returned type after indexing.
Source§

fn index(&self, key: RangeToInclusive<usize>) -> &Slice<V>

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> Index<usize> for Slice<V>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, key: usize) -> &V

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<(Bound<usize>, Bound<usize>)> for Slice<V>

Source§

fn index_mut(&mut self, key: (Bound<usize>, Bound<usize>)) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<Range<usize>> for Slice<V>

Source§

fn index_mut(&mut self, key: Range<usize>) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<RangeFrom<usize>> for Slice<V>

Source§

fn index_mut(&mut self, key: RangeFrom<usize>) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<RangeFull> for Slice<V>

Source§

fn index_mut(&mut self, key: RangeFull) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<RangeInclusive<usize>> for Slice<V>

Source§

fn index_mut(&mut self, key: RangeInclusive<usize>) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<RangeTo<usize>> for Slice<V>

Source§

fn index_mut(&mut self, key: RangeTo<usize>) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<RangeToInclusive<usize>> for Slice<V>

Source§

fn index_mut(&mut self, key: RangeToInclusive<usize>) -> &mut Slice<V>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<usize> for Slice<V>

Source§

fn index_mut(&mut self, key: usize) -> &mut V

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, V> IntoIterator for &'a Slice<V>

Source§

type Item = (&'a Entity, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, V>

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

fn into_iter(self) -> <&'a Slice<V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, V> IntoIterator for &'a mut Slice<V>

Source§

type Item = (&'a Entity, &'a mut V)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, V>

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

fn into_iter(self) -> <&'a mut Slice<V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V> IntoIterator for Box<Slice<V>>

Source§

type Item = (Entity, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<V>

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

fn into_iter(self) -> <Box<Slice<V>> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V> Ord for Slice<V>
where V: Ord,

Source§

fn cmp(&self, other: &Slice<V>) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<V> PartialEq for Slice<V>
where V: PartialEq,

Source§

fn eq(&self, other: &Slice<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V> PartialOrd for Slice<V>
where V: PartialOrd,

Source§

fn partial_cmp(&self, other: &Slice<V>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V> Eq for Slice<V>
where V: Eq,

Auto Trait Implementations§

§

impl<V, S> Freeze for Slice<V, S>
where V: Freeze,

§

impl<V, S> RefUnwindSafe for Slice<V, S>

§

impl<V, S> Send for Slice<V, S>
where S: Send, V: Send,

§

impl<V, S = EntityHash> !Sized for Slice<V, S>

§

impl<V, S> Sync for Slice<V, S>
where S: Sync, V: Sync,

§

impl<V, S> Unpin for Slice<V, S>
where S: Unpin, V: Unpin,

§

impl<V, S> UnwindSafe for Slice<V, S>
where S: 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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.