Struct Slice

Source
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

Source

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

Returns an empty slice.

Equivalent to set::Slice::new.

Source

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.

Source

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.

Source

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

Casts self to the inner slice.

Source

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.

Source

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

Casts a reference to self to the inner slice.

Source

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

Casts self to the inner slice.

Source

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.

Source

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

Divides one slice into two at an index.

Equivalent to set::Slice::split_at.

Source

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.

Source

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.

Source

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

Source

pub fn len(&self) -> usize

Return the number of elements in the set slice.

Source

pub fn is_empty(&self) -> bool

Returns true if the set slice contains no elements.

Source

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

Get a value by index.

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

Source

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().

Source

pub fn first(&self) -> Option<&T>

Get the first value.

Source

pub fn last(&self) -> Option<&T>

Get the last value.

Source

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

Divides one slice into two at an index.

Panics if index > len.

Source

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.

Source

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.

Source

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

Return an iterator over the values of the set slice.

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.

Source

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

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.

Source

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

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.

Source

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

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 Clone for Box<Slice>

Source§

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

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 Default for &Slice

Source§

fn default() -> &Slice

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

impl Default for Box<Slice>

Source§

fn default() -> Box<Slice>

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

impl Deref for Slice

Source§

type Target = Slice<Entity>

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl From<&Slice> for Box<Slice>

Source§

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

Converts to this type from the input type.
Source§

impl Hash for Slice

Source§

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

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

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

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<Range<usize>> for Slice

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<RangeFrom<usize>> for Slice

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<RangeFull> for Slice

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<RangeInclusive<usize>> for Slice

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<RangeTo<usize>> for Slice

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<RangeToInclusive<usize>> for Slice

Source§

type Output = Slice

The returned type after indexing.
Source§

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

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

impl Index<usize> for Slice

Source§

type Output = Entity

The returned type after indexing.
Source§

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

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

impl<'a> IntoIterator for &'a Slice

Source§

type IntoIter = Iter<'a>

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

type Item = &'a Entity

The type of the elements being iterated over.
Source§

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

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Box<Slice>

Source§

type IntoIter = IntoIter

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

type Item = Entity

The type of the elements being iterated over.
Source§

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

Creates an iterator from a value. Read more
Source§

impl Ord for Slice

Source§

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

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

impl PartialEq for Slice

Source§

fn eq(&self, other: &Slice) -> 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 PartialOrd for Slice

Source§

fn partial_cmp(&self, other: &Slice) -> 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 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> 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.