pub struct Slice<S = EntityHash>(/* private fields */);
Expand description
A dynamically-sized slice of values in an EntityIndexSet
.
Equivalent to an indexmap::set::Slice<V>
whose source IndexSet
uses EntityHash
.
Implementations§
Source§impl Slice
impl Slice
Sourcepub const fn new<'a>() -> &'a Slice
pub const fn new<'a>() -> &'a Slice
Returns an empty slice.
Equivalent to set::Slice::new
.
Sourcepub const unsafe fn from_slice_unchecked(slice: &Slice<Entity>) -> &Slice
pub const unsafe fn from_slice_unchecked(slice: &Slice<Entity>) -> &Slice
Constructs a entity::index_set::Slice
from a indexmap::set::Slice
unsafely.
§Safety
slice
must stem from an IndexSet
using EntityHash
.
Sourcepub const unsafe fn from_slice_unchecked_mut(
slice: &mut Slice<Entity>,
) -> &mut Slice
pub const unsafe fn from_slice_unchecked_mut( slice: &mut Slice<Entity>, ) -> &mut Slice
Constructs a entity::index_set::Slice
from a indexmap::set::Slice
unsafely.
§Safety
slice
must stem from an IndexSet
using EntityHash
.
Sourcepub unsafe fn from_boxed_slice_unchecked(
slice: Box<Slice<Entity>>,
) -> Box<Slice>
pub unsafe fn from_boxed_slice_unchecked( slice: Box<Slice<Entity>>, ) -> Box<Slice>
Constructs a boxed entity::index_set::Slice
from a boxed indexmap::set::Slice
unsafely.
§Safety
slice
must stem from an IndexSet
using EntityHash
.
Sourcepub fn as_boxed_inner(self: &Box<Slice>) -> &Box<Slice<Entity>>
pub fn as_boxed_inner(self: &Box<Slice>) -> &Box<Slice<Entity>>
Casts a reference to self
to the inner slice.
Sourcepub fn get_range<R>(&self, range: R) -> Option<&Slice>where
R: RangeBounds<usize>,
pub fn get_range<R>(&self, range: R) -> Option<&Slice>where
R: RangeBounds<usize>,
Returns a slice of values in the given range of indices.
Equivalent to set::Slice::get_range
.
Sourcepub fn split_at(&self, index: usize) -> (&Slice, &Slice)
pub fn split_at(&self, index: usize) -> (&Slice, &Slice)
Divides one slice into two at an index.
Equivalent to set::Slice::split_at
.
Sourcepub fn split_first(&self) -> Option<(&Entity, &Slice)>
pub fn split_first(&self) -> Option<(&Entity, &Slice)>
Returns the first value and the rest of the slice,
or None
if it is empty.
Equivalent to set::Slice::split_first
.
Sourcepub fn split_last(&self) -> Option<(&Entity, &Slice)>
pub fn split_last(&self) -> Option<(&Entity, &Slice)>
Returns the last value and the rest of the slice,
or None
if it is empty.
Equivalent to set::Slice::split_last
.
Sourcepub fn iter(&self) -> Iter<'_> ⓘ
pub fn iter(&self) -> Iter<'_> ⓘ
Return an iterator over the values of the set slice.
Equivalent to set::Slice::iter
.
Methods from Deref<Target = Slice<Entity>>§
Sourcepub fn get_index(&self, index: usize) -> Option<&T>
pub fn get_index(&self, index: usize) -> Option<&T>
Get a value by index.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn get_range<R>(&self, range: R) -> Option<&Slice<T>>where
R: RangeBounds<usize>,
pub fn get_range<R>(&self, range: R) -> Option<&Slice<T>>where
R: RangeBounds<usize>,
Returns a slice of values in the given range of indices.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn split_at(&self, index: usize) -> (&Slice<T>, &Slice<T>)
pub fn split_at(&self, index: usize) -> (&Slice<T>, &Slice<T>)
Divides one slice into two at an index.
Panics if index > len
.
Sourcepub fn split_first(&self) -> Option<(&T, &Slice<T>)>
pub fn split_first(&self) -> Option<(&T, &Slice<T>)>
Returns the first value and the rest of the slice,
or None
if it is empty.
Sourcepub fn split_last(&self) -> Option<(&T, &Slice<T>)>
pub fn split_last(&self) -> Option<(&T, &Slice<T>)>
Returns the last value and the rest of the slice,
or None
if it is empty.
Sourcepub fn binary_search(&self, x: &T) -> Result<usize, usize>where
T: Ord,
pub fn binary_search(&self, x: &T) -> Result<usize, usize>where
T: Ord,
Search over a sorted set for a value.
Returns the position where that value 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 value up in
the set this is a slice from using IndexSet::get_index_of
, but this can also position
missing values.
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 set 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 set 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 set 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> IntoIterator for &'a Slice
impl<'a> IntoIterator for &'a Slice
Source§impl IntoIterator for Box<Slice>
impl IntoIterator for Box<Slice>
Source§impl PartialOrd for Slice
impl PartialOrd for Slice
impl Eq for Slice
Auto Trait Implementations§
impl<S> Freeze for Slice<S>
impl<S> RefUnwindSafe for Slice<S>where
S: RefUnwindSafe,
impl<S> Send for Slice<S>where
S: Send,
impl<S = EntityHash> !Sized for Slice<S>
impl<S> Sync for Slice<S>where
S: Sync,
impl<S> Unpin for Slice<S>where
S: Unpin,
impl<S> UnwindSafe for Slice<S>where
S: 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.