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>
impl<V> Slice<V>
Sourcepub const fn new<'a>() -> &'a Slice<V>
pub const fn new<'a>() -> &'a Slice<V>
Returns an empty slice.
Equivalent to map::Slice::new
.
Sourcepub fn new_mut<'a>() -> &'a mut Slice<V>
pub fn new_mut<'a>() -> &'a mut Slice<V>
Returns an empty mutable slice.
Equivalent to map::Slice::new_mut
.
Sourcepub const unsafe fn from_slice_unchecked(slice: &Slice<Entity, V>) -> &Slice<V>
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
.
Sourcepub const unsafe fn from_slice_unchecked_mut(
slice: &mut Slice<Entity, V>,
) -> &mut Slice<V>
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
.
Sourcepub unsafe fn from_boxed_slice_unchecked(
slice: Box<Slice<Entity, V>>,
) -> Box<Slice<V>>
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
.
Sourcepub fn as_boxed_inner(self: &Box<Slice<V>>) -> &Box<Slice<Entity, V>>
pub fn as_boxed_inner(self: &Box<Slice<V>>) -> &Box<Slice<Entity, V>>
Casts a reference to self
to the inner slice.
Sourcepub fn into_boxed_inner(self: Box<Slice<V>>) -> Box<Slice<Entity, V>>
pub fn into_boxed_inner(self: Box<Slice<V>>) -> Box<Slice<Entity, V>>
Casts self
to the inner slice.
Sourcepub fn get_index_mut(&mut self, index: usize) -> Option<(&Entity, &mut V)>
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
.
Sourcepub fn get_range<R>(&self, range: R) -> Option<&Slice<V>>where
R: RangeBounds<usize>,
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
.
Sourcepub fn get_range_mut<R>(&mut self, range: R) -> Option<&mut Slice<V>>where
R: RangeBounds<usize>,
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
.
Sourcepub fn first_mut(&mut self) -> Option<(&Entity, &mut V)>
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
.
Sourcepub fn last_mut(&mut self) -> Option<(&Entity, &mut V)>
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
.
Sourcepub fn split_at(&self, index: usize) -> (&Slice<V>, &Slice<V>)
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
.
Sourcepub fn split_at_mut(&mut self, index: usize) -> (&mut Slice<V>, &mut Slice<V>)
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
.
Sourcepub fn split_first(&self) -> Option<((&Entity, &V), &Slice<V>)>
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
.
Sourcepub fn split_first_mut(&mut self) -> Option<((&Entity, &mut V), &mut Slice<V>)>
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
.
Sourcepub fn split_last(&self) -> Option<((&Entity, &V), &Slice<V>)>
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
.
Sourcepub fn split_last_mut(&mut self) -> Option<((&Entity, &mut V), &mut Slice<V>)>
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
.
Sourcepub fn iter(&self) -> Iter<'_, V> ⓘ
pub fn iter(&self) -> Iter<'_, V> ⓘ
Return an iterator over the key-value pairs of the map slice.
Equivalent to map::Slice::iter
.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, V> ⓘ
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
.
Sourcepub fn keys(&self) -> Keys<'_, V> ⓘ
pub fn keys(&self) -> Keys<'_, V> ⓘ
Return an iterator over the keys of the map slice.
Equivalent to map::Slice::keys
.
Sourcepub fn into_keys(self: Box<Slice<V>>) -> IntoKeys<V> ⓘ
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
.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, Entity, V> ⓘ
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
.
Sourcepub fn into_values(self: Box<Slice<V>>) -> IntoValues<Entity, V> ⓘ
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>>§
Sourcepub fn get_index(&self, index: usize) -> Option<(&K, &V)>
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
Get a key-value pair by index.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn get_range<R>(&self, range: R) -> Option<&Slice<K, V>>where
R: RangeBounds<usize>,
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()
.
Sourcepub fn split_at(&self, index: usize) -> (&Slice<K, V>, &Slice<K, V>)
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
.
Sourcepub fn split_first(&self) -> Option<((&K, &V), &Slice<K, V>)>
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.
Sourcepub fn split_last(&self) -> Option<((&K, &V), &Slice<K, V>)>
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.
Sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
Return an iterator over the key-value pairs of the map slice.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
Return an iterator over the values of the map slice.
Sourcepub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
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.
Sourcepub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
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.
Sourcepub fn binary_search_by_key<'a, B, F>(
&'a self,
b: &B,
f: F,
) -> Result<usize, usize>
pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize>
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.
Sourcepub fn partition_point<P>(&self, pred: P) -> usize
pub fn partition_point<P>(&self, pred: P) -> usize
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<'a, V> IntoIterator for &'a Slice<V>
impl<'a, V> IntoIterator for &'a Slice<V>
Source§impl<'a, V> IntoIterator for &'a mut Slice<V>
impl<'a, V> IntoIterator for &'a mut Slice<V>
Source§impl<V> IntoIterator for Box<Slice<V>>
impl<V> IntoIterator for Box<Slice<V>>
Source§impl<V> PartialOrd for Slice<V>where
V: PartialOrd,
impl<V> PartialOrd for Slice<V>where
V: PartialOrd,
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>where
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, S> Send for Slice<V, S>
impl<V, S = EntityHash> !Sized for Slice<V, S>
impl<V, S> Sync for Slice<V, S>
impl<V, S> Unpin for Slice<V, S>
impl<V, S> UnwindSafe for Slice<V, S>where
S: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.