Struct Slice

struct Slice<T> { ... }

A dynamically-sized slice of values in an IndexSet.

This supports indexed operations much like a [T] slice, but not any hashed operations on the values.

Unlike IndexSet, Slice does consider the order for PartialEq and Eq, and it also implements PartialOrd, Ord, and Hash.

Implementations

impl<T> Slice<T>

const fn new<'a>() -> &'a Self

Returns an empty slice.

const fn len(self: &Self) -> usize

Return the number of elements in the set slice.

const fn is_empty(self: &Self) -> bool

Returns true if the set slice contains no elements.

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

Get a value by index.

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

fn get_range<R: RangeBounds<usize>>(self: &Self, range: R) -> Option<&Self>

Returns a slice of values in the given range of indices.

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

fn first(self: &Self) -> Option<&T>

Get the first value.

fn last(self: &Self) -> Option<&T>

Get the last value.

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

Divides one slice into two at an index.

Panics if index > len.

fn split_first(self: &Self) -> Option<(&T, &Self)>

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

fn split_last(self: &Self) -> Option<(&T, &Self)>

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

fn iter(self: &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.

fn binary_search_by<'a, F>(self: &'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.

fn binary_search_by_key<'a, B, F>(self: &'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.

fn partition_point<P>(self: &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.

impl<Q, K> Comparable for Slice<T>

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

impl<Q, K> Equivalent for Slice<T>

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

impl<Q, K> Equivalent for Slice<T>

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

impl<T> Any for Slice<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Slice<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Slice<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> Freeze for Slice<T>

impl<T> Index for Slice<T>

fn index(self: &Self, range: Range<usize>) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, range: RangeTo<usize>) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, range: RangeFrom<usize>) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, range: RangeToInclusive<usize>) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, range: RangeFull) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, range: (Bound<usize>, Bound<usize>)) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, index: usize) -> &<Self as >::Output

impl<T> Index for Slice<T>

fn index(self: &Self, range: RangeInclusive<usize>) -> &<Self as >::Output

impl<T> RefUnwindSafe for Slice<T>

impl<T> Send for Slice<T>

impl<T> Sized for Slice<T>

impl<T> Sync for Slice<T>

impl<T> Unpin for Slice<T>

impl<T> UnsafeUnpin for Slice<T>

impl<T> UnwindSafe for Slice<T>

impl<T, U> PartialEq for Slice<T>

fn eq(self: &Self, other: &[U]) -> bool

impl<T, U> PartialEq for Slice<T>

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

impl<T, U, N: usize> PartialEq for Slice<T>

fn eq(self: &Self, other: &[U; N]) -> bool

impl<T: Eq> Eq for Slice<T>

impl<T: Hash> Hash for Slice<T>

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

impl<T: Ord> Ord for Slice<T>

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

impl<T: PartialOrd> PartialOrd for Slice<T>

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

impl<T: fmt::Debug> Debug for Slice<T>

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