Struct typed_index_collections::TiVec[][src]

pub struct TiVec<K, V> {
    pub raw: Vec<V>,
    // some fields omitted
}
Expand description

A contiguous growable array type that only accepts keys of the type K.

TiVec<K, V> is a wrapper around Rust container type std::vec::Vec. The struct mirrors the stable API of Rust std::vec::Vec and forwards to it as much as possible.

TiVec<K, V> uses K instead of usize for element indices and require the index to implement From<usize> and Into<usize> traits. Their implementation can be easily done with derive_more crate and #[derive(From, Into)].

TiVec<K, V> can be converted to std::vec::Vec<V> and back using From and Into.

There are also zero-cost conversions available between references:

Added methods:

  • from_ref - Converts a &std::vec::Vec<V> into a &TiVec<K, V>.
  • from_mut - Converts a &mut std::vec::Vec<V> into a &mut TiVec<K, V>.
  • push_and_get_key - Appends an element to the back of a collection and returns its index of type K.
  • pop_key_value - Removes the last element from a vector and returns it with its index of type K, or None if the vector is empty.
  • drain_enumerated - Creates a draining iterator that removes the specified range in the vector and yields the current count and the removed items. It acts like self.drain(range).enumerate(), but instead of usize it returns index of type K.
  • into_iter_enumerated - Converts the vector into iterator over all key-value pairs with K used for iteration indices. It acts like self.into_iter().enumerate(), but use K instead of usize for iteration indices.

Example

use typed_index_collections::TiVec;
use derive_more::{From, Into};

#[derive(From, Into)]
struct FooId(usize);

let mut foos: TiVec<FooId, usize> = std::vec![10, 11, 13].into();
foos.insert(FooId(2), 12);
assert_eq!(foos[FooId(2)], 12);

Fields

raw: Vec<V>

Raw slice property

Implementations

impl<K, V> TiVec<K, V>[src]

pub fn new() -> Self[src]

Constructs a new, empty TiVec<K, V>.

See Vec::new for more details.

pub fn with_capacity(capacity: usize) -> Self[src]

Constructs a new, empty TiVec<K, V> with the specified capacity.

See Vec::with_capacity for more details.

pub unsafe fn from_raw_parts(
    ptr: *mut V,
    length: usize,
    capacity: usize
) -> Self
[src]

Creates a TiVec<K, V> directly from the raw components of another vector.

See Vec::from_raw_parts for more details.

pub fn from_ref(raw: &Vec<V>) -> &Self[src]

Converts a &std::vec::Vec<V> into a &TiVec<K, V>.

Vector reference is intentionally used in the argument instead of slice reference for conversion with no-op.

Example

pub struct Id(usize);
let vec: &TiVec<Id, usize> = TiVec::from_ref(&vec![1, 2, 4]);

pub fn from_mut(raw: &mut Vec<V>) -> &mut Self[src]

Converts a [&mut std::vec::Vec<V>] into a &mut TiVec<K, V>.

Example

pub struct Id(usize);
let vec: &mut TiVec<Id, usize> = TiVec::from_mut(&mut vec![1, 2, 4]);

pub fn capacity(&self) -> usize[src]

Returns the number of elements the vector can hold without reallocating.

See Vec::capacity for more details.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more elements to be inserted in the given TiVec<K, V>. The collection may reserve more space to avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.

See Vec::reserve for more details.

pub fn reserve_exact(&mut self, additional: usize)[src]

Reserves the minimum capacity for exactly additional more elements to be inserted in the given TiVec<K, V>. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.

See Vec::reserve_exact for more details.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the vector as much as possible.

See Vec::shrink_to_fit for more details.

pub fn into_boxed_slice(self) -> Box<TiSlice<K, V>>[src]

Converts the vector into Box<TiSlice<K, V>>.

See Vec::into_boxed_slice for more details.

pub fn truncate(&mut self, len: usize)[src]

Shortens the vector, keeping the first len elements and dropping the rest.

See Vec::truncate for more details.

pub fn as_slice(&self) -> &TiSlice<K, V>[src]

Extracts a slice containing the entire vector.

See Vec::as_slice for more details.

pub fn as_mut_slice(&mut self) -> &mut TiSlice<K, V>[src]

Extracts a mutable slice of the entire vector.

See Vec::as_mut_slice for more details.

pub fn as_ptr(&self) -> *const V[src]

Returns a raw pointer to the vector’s buffer.

See Vec::as_ptr for more details.

pub fn as_mut_ptr(&mut self) -> *mut V[src]

Returns an unsafe mutable pointer to the vector’s buffer.

See Vec::as_mut_ptr for more details.

pub unsafe fn set_len(&mut self, new_len: usize)[src]

Forces the length of the vector to new_len.

See Vec::set_len for more details.

pub fn swap_remove(&mut self, index: K) -> V where
    usize: From<K>, 
[src]

Removes an element from the vector and returns it.

The removed element is replaced by the last element of the vector.

See Vec::swap_remove for more details.

pub fn insert(&mut self, index: K, element: V) where
    usize: From<K>, 
[src]

Inserts an element at position index within the vector, shifting all elements after it to the right.

See Vec::insert for more details.

pub fn remove(&mut self, index: K) -> V where
    usize: From<K>, 
[src]

Removes and returns the element at position index within the vector, shifting all elements after it to the left.

See Vec::remove for more details.

pub fn retain<F>(&mut self, f: F) where
    F: FnMut(&V) -> bool
[src]

Retains only the elements specified by the predicate.

See Vec::retain for more details.

pub fn dedup_by_key<F, K2>(&mut self, key: F) where
    F: FnMut(&mut V) -> K2,
    K2: PartialEq
[src]

Removes all but the first of consecutive elements in the vector that resolve to the same key.

See Vec::dedup_by_key for more details.

pub fn dedup_by<F>(&mut self, same_bucket: F) where
    F: FnMut(&mut V, &mut V) -> bool
[src]

Removes all but the first of consecutive elements in the vector satisfying a given equality relation.

See Vec::dedup_by for more details.

pub fn push(&mut self, value: V)[src]

Appends an element to the back of a collection.

See Vec::push for more details.

pub fn push_and_get_key(&mut self, value: V) -> K where
    K: From<usize>, 
[src]

Appends an element to the back of a collection and returns its index of type K.

It acts like { vec.push(...); vec.last_key().unwrap() }, but is optimized better.

See Vec::push for more details.

Example

#[derive(Eq, Debug, From, Into, PartialEq)]
pub struct Id(usize);
let mut vec: TiVec<Id, usize> = vec![1, 2, 4].into();
assert_eq!(vec.push_and_get_key(8), Id(3));
assert_eq!(vec.push_and_get_key(16), Id(4));
assert_eq!(vec.push_and_get_key(32), Id(5));

pub fn pop(&mut self) -> Option<V>[src]

Removes the last element from a vector and returns it, or None if it is empty.

See Vec::pop for more details.

pub fn pop_key_value(&mut self) -> Option<(K, V)> where
    K: From<usize>, 
[src]

Removes the last element from a vector and returns it with its index of type K, or None if the vector is empty.

See Vec::pop for more details.

Example

#[derive(Eq, Debug, From, Into, PartialEq)]
pub struct Id(usize);
let mut vec: TiVec<Id, usize> = vec![1, 2, 4].into();
assert_eq!(vec.pop_key_value(), Some((Id(2), 4)));
assert_eq!(vec.pop_key_value(), Some((Id(1), 2)));
assert_eq!(vec.pop_key_value(), Some((Id(0), 1)));
assert_eq!(vec.pop_key_value(), None);

pub fn append(&mut self, other: &mut Self)[src]

Moves all the elements of other into Self, leaving other empty.

See Vec::append for more details.

pub fn drain<R>(&mut self, range: R) -> Drain<'_, V> where
    R: TiRangeBounds<K>, 
[src]

Creates a draining iterator that removes the specified range in the vector and yields the removed items.

See Vec::drain for more details.

pub fn drain_enumerated<R>(
    &mut self,
    range: R
) -> TiEnumerated<Drain<'_, V>, K, V> where
    K: From<usize>,
    R: TiRangeBounds<K>, 
[src]

Creates a draining iterator that removes the specified range in the vector and yields the current count and the removed items.

It acts like self.drain(range).enumerate(), but instead of usize it returns index of type K.

Note that the indices started from K::from_usize(0), regardless of the range starting point.

See Vec::drain for more details.

Example

#[derive(Eq, Debug, From, Into, PartialEq)]
pub struct Id(usize);
let mut vec: TiVec<Id, usize> = vec![1, 2, 4].into();
{
    let mut iterator = vec.drain_enumerated(Id(1)..);
    assert_eq!(iterator.next(), Some((Id(0), 2)));
    assert_eq!(iterator.next(), Some((Id(1), 4)));
    assert_eq!(iterator.next(), None);
}
assert_eq!(vec.as_slice(), TiSlice::from_ref(&[1]));

pub fn clear(&mut self)[src]

Clears the vector, removing all values.

See Vec::clear for more details.

pub fn len(&self) -> usize[src]

Returns the number of elements in the vector, also referred to as its ‘length’.

See Vec::len for more details.

pub fn is_empty(&self) -> bool[src]

Returns true if the vector contains no elements.

See Vec::is_empty for more details.

#[must_use = "use `.truncate()` if you don't need the other half"]
pub fn split_off(&mut self, at: K) -> Self where
    usize: From<K>, 
[src]

Splits the collection into two at the given index.

See Vec::split_off for more details.

pub fn resize_with<F>(&mut self, new_len: usize, f: F) where
    F: FnMut() -> V, 
[src]

Resizes the TiVec in-place so that len is equal to new_len.

See Vec::resize_with for more details.

pub fn resize(&mut self, new_len: usize, value: V) where
    V: Clone
[src]

Resizes the TiVec in-place so that len is equal to new_len.

See Vec::resize for more details.

pub fn extend_from_slice(&mut self, other: &TiSlice<K, V>) where
    V: Clone
[src]

Clones and appends all elements in a slice to the TiVec.

See Vec::extend_from_slice for more details.

pub fn dedup(&mut self) where
    V: PartialEq
[src]

Removes consecutive repeated elements in the vector according to the PartialEq trait implementation.

See Vec::dedup for more details.

pub fn splice<R, I>(
    &mut self,
    range: R,
    replace_with: I
) -> Splice<'_, I::IntoIter> where
    R: TiRangeBounds<K>,
    I: IntoIterator<Item = V>, 
[src]

Creates a splicing iterator that replaces the specified range in the vector with the given replace_with iterator and yields the removed items. replace_with does not need to be the same length as range.

See Vec::splice for more details.

pub fn into_iter_enumerated(self) -> TiEnumerated<IntoIter<V>, K, V> where
    K: From<usize>, 
[src]

Converts the vector into iterator over all key-value pairs with K used for iteration indices.

It acts like self.into_iter().enumerate(), but use K instead of usize for iteration indices.

Example

#[derive(Eq, Debug, From, Into, PartialEq)]
pub struct Id(usize);
let vec: TiVec<Id, usize> = vec![1, 2, 4].into();
let mut iterator = vec.into_iter_enumerated();
assert_eq!(iterator.next(), Some((Id(0), 1)));
assert_eq!(iterator.next(), Some((Id(1), 2)));
assert_eq!(iterator.next(), Some((Id(2), 4)));
assert_eq!(iterator.next(), None);

Methods from Deref<Target = TiSlice<K, V>>

pub fn len(&self) -> usize[src]

Returns the number of elements in the slice.

See slice::len for more details.

pub fn next_key(&self) -> K where
    K: From<usize>, 
[src]

Returns the index of the next slice element to be appended and at the same time number of elements in the slice of type K.

Example

#[derive(Eq, Debug, From, Into, PartialEq)]
pub struct Id(usize);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
assert_eq!(slice.next_key(), Id(3));

pub const fn is_empty(&self) -> bool[src]

Returns true if the slice has a length of 0.

See slice::is_empty for more details.

pub fn keys(&self) -> TiSliceKeys<K> where
    K: From<usize>, 
[src]

Returns an iterator over all keys.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
let mut iterator = slice.keys();
assert_eq!(iterator.next(), Some(Id(0)));
assert_eq!(iterator.next(), Some(Id(1)));
assert_eq!(iterator.next(), Some(Id(2)));
assert_eq!(iterator.next(), None);

pub fn first(&self) -> Option<&V>[src]

Returns the first element of the slice, or None if it is empty.

See slice::first for more details.

pub fn first_mut(&mut self) -> Option<&mut V>[src]

Returns a mutable reference to the first element of the slice, or None if it is empty.

See slice::first_mut for more details.

pub fn first_key(&self) -> Option<K> where
    K: From<usize>, 
[src]

Returns the first slice element index of type K, or None if the slice is empty.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
assert_eq!(empty_slice.first_key(), None);
assert_eq!(slice.first_key(), Some(Id(0)));

pub fn first_key_value(&self) -> Option<(K, &V)> where
    K: From<usize>, 
[src]

Returns the first slice element index of type K and the element itself, or None if the slice is empty.

See slice::first for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
assert_eq!(empty_slice.first_key_value(), None);
assert_eq!(slice.first_key_value(), Some((Id(0), &1)));

pub fn first_key_value_mut(&mut self) -> Option<(K, &mut V)> where
    K: From<usize>, 
[src]

Returns the first slice element index of type K and a mutable reference to the element itself, or None if the slice is empty.

See slice::first_mut for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let empty_slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut []);
let mut array = [1, 2, 4];
let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut array);
assert_eq!(empty_slice.first_key_value_mut(), None);
assert_eq!(slice.first_key_value_mut(), Some((Id(0), &mut 1)));
*slice.first_key_value_mut().unwrap().1 = 123;
assert_eq!(slice.raw, [123, 2, 4]);

pub fn split_first(&self) -> Option<(&V, &TiSlice<K, V>)>[src]

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

See slice::split_first for more details.

pub fn split_first_mut(&mut self) -> Option<(&mut V, &mut TiSlice<K, V>)>[src]

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

See slice::split_first_mut for more details.

pub fn split_last(&self) -> Option<(&V, &TiSlice<K, V>)>[src]

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

See slice::split_last for more details.

pub fn split_last_mut(&mut self) -> Option<(&mut V, &mut TiSlice<K, V>)>[src]

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

See slice::split_last_mut for more details.

pub fn last(&self) -> Option<&V>[src]

Returns the last element of the slice of type K, or None if it is empty.

See slice::last for more details.

pub fn last_mut(&mut self) -> Option<&mut V>[src]

Returns a mutable reference to the last item in the slice.

See slice::last_mut for more details.

pub fn last_key(&self) -> Option<K> where
    K: From<usize>, 
[src]

Returns the last slice element index of type K, or None if the slice is empty.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
assert_eq!(empty_slice.last_key(), None);
assert_eq!(slice.last_key(), Some(Id(2)));

pub fn last_key_value(&self) -> Option<(K, &V)> where
    K: From<usize>, 
[src]

Returns the last slice element index of type K and the element itself, or None if the slice is empty.

See slice::last for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
assert_eq!(empty_slice.last_key_value(), None);
assert_eq!(slice.last_key_value(), Some((Id(2), &4)));

pub fn last_key_value_mut(&mut self) -> Option<(K, &mut V)> where
    K: From<usize>, 
[src]

Returns the last slice element index of type K and a mutable reference to the element itself, or None if the slice is empty.

See slice::last_mut for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let empty_slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut []);
let mut array = [1, 2, 4];
let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut array);
assert_eq!(empty_slice.last_key_value_mut(), None);
assert_eq!(slice.last_key_value_mut(), Some((Id(2), &mut 4)));
*slice.last_key_value_mut().unwrap().1 = 123;
assert_eq!(slice.raw, [1, 2, 123]);

pub fn get<I>(&self, index: I) -> Option<&I::Output> where
    I: TiSliceIndex<K, V>, 
[src]

Returns a reference to an element or subslice depending on the type of index or None if the index is out of bounds.

See slice::get for more details.

pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output> where
    I: TiSliceIndex<K, V>, 
[src]

Returns a mutable reference to an element or subslice depending on the type of index or None if the index is out of bounds.

See slice::get_mut for more details.

pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output where
    I: TiSliceIndex<K, V>, 
[src]

Returns a reference to an element or subslice depending on the type of index, without doing bounds checking.

This is generally not recommended, use with caution! Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used. For a safe alternative see get.

See slice::get_unchecked for more details.

pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output where
    I: TiSliceIndex<K, V>, 
[src]

Returns a mutable reference to an element or subslice depending on the type of index, without doing bounds checking.

This is generally not recommended, use with caution! Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used. For a safe alternative see get_mut.

See slice::get_unchecked_mut for more details.

pub const fn as_ptr(&self) -> *const V[src]

Returns a raw pointer to the slice’s buffer.

See slice::as_ptr for more details.

pub fn as_mut_ptr(&mut self) -> *mut V[src]

Returns an unsafe mutable reference to the slice’s buffer.

See slice::as_mut_ptr for more details.

pub fn swap(&mut self, a: K, b: K) where
    usize: From<K>, 
[src]

Swaps two elements in the slice.

See slice::swap for more details.

pub fn reverse(&mut self)[src]

Reverses the order of elements in the slice, in place.

See slice::reverse for more details.

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

Returns an iterator over the slice.

See slice::iter for more details.

pub fn iter_enumerated(&self) -> TiEnumerated<Iter<'_, V>, K, &V> where
    K: From<usize>, 
[src]

Returns an iterator over all key-value pairs.

It acts like self.iter().enumerate(), but use K instead of usize for iteration indices.

See slice::iter for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
let mut iterator = slice.iter_enumerated();
assert_eq!(iterator.next(), Some((Id(0), &1)));
assert_eq!(iterator.next(), Some((Id(1), &2)));
assert_eq!(iterator.next(), Some((Id(2), &4)));
assert_eq!(iterator.next(), None);

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

Returns an iterator that allows modifying each value.

See slice::iter_mut for more details.

pub fn iter_mut_enumerated(&mut self) -> TiEnumerated<IterMut<'_, V>, K, &mut V> where
    K: From<usize>, 
[src]

Returns an iterator over all key-value pairs, with mutable references to the values.

It acts like self.iter_mut().enumerate(), but use K instead of usize for iteration indices.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let mut array = [1, 2, 4];
let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut array);
for (key, value) in slice.iter_mut_enumerated() {
    *value += key.0;
}
assert_eq!(array, [1, 3, 6]);

pub fn position<P>(&self, predicate: P) -> Option<K> where
    K: From<usize>,
    P: FnMut(&V) -> bool
[src]

Searches for an element in an iterator, returning its index of type K.

It acts like self.iter().position(...), but instead of usize it returns index of type K.

See slice::iter and Iterator::position for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4, 2, 1]);
assert_eq!(slice.position(|&value| value == 1), Some(Id(0)));
assert_eq!(slice.position(|&value| value == 2), Some(Id(1)));
assert_eq!(slice.position(|&value| value == 3), None);
assert_eq!(slice.position(|&value| value == 4), Some(Id(2)));

pub fn rposition<P>(&self, predicate: P) -> Option<K> where
    K: From<usize>,
    P: FnMut(&V) -> bool
[src]

Searches for an element in an iterator from the right, returning its index of type K.

It acts like self.iter().rposition(...), but instead of usize it returns index of type K.

See slice::iter and Iterator::position for more details.

Example

#[derive(Debug, Eq, From, Into, PartialEq)]
pub struct Id(usize);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4, 2, 1]);
assert_eq!(slice.rposition(|&value| value == 1), Some(Id(4)));
assert_eq!(slice.rposition(|&value| value == 2), Some(Id(3)));
assert_eq!(slice.rposition(|&value| value == 3), None);
assert_eq!(slice.rposition(|&value| value == 4), Some(Id(2)));

pub fn windows(&self, size: usize) -> TiSliceRefMap<Windows<'_, V>, K, V>[src]

Returns an iterator over all contiguous windows of length size. The windows overlap. If the slice is shorter than size, the iterator returns no values.

See slice::windows for more details.

pub fn chunks(&self, chunk_size: usize) -> TiSliceRefMap<Chunks<'_, V>, K, V>[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the beginning of the slice.

See slice::chunks for more details.

pub fn chunks_mut(
    &mut self,
    chunk_size: usize
) -> TiSliceMutMap<ChunksMut<'_, V>, K, V>
[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the beginning of the slice.

See slice::chunks_mut for more details.

pub fn chunks_exact(
    &self,
    chunk_size: usize
) -> TiSliceRefMap<ChunksExact<'_, V>, K, V>
[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the beginning of the slice.

See slice::chunks_exact for more details.

pub fn chunks_exact_mut(
    &mut self,
    chunk_size: usize
) -> TiSliceMutMap<ChunksExactMut<'_, V>, K, V>
[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the beginning of the slice.

See slice::chunks_exact_mut for more details.

pub fn rchunks(&self, chunk_size: usize) -> TiSliceRefMap<RChunks<'_, V>, K, V>[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice.

See slice::rchunks for more details.

pub fn rchunks_mut(
    &mut self,
    chunk_size: usize
) -> TiSliceMutMap<RChunksMut<'_, V>, K, V>
[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice.

See slice::rchunks_mut for more details.

pub fn rchunks_exact(
    &self,
    chunk_size: usize
) -> TiSliceRefMap<RChunksExact<'_, V>, K, V>
[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice.

See slice::rchunks_exact for more details.

pub fn rchunks_exact_mut(
    &mut self,
    chunk_size: usize
) -> TiSliceMutMap<RChunksExactMut<'_, V>, K, V>
[src]

Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice.

See slice::rchunks_exact_mut for more details.

pub fn split_at(&self, mid: K) -> (&Self, &Self) where
    usize: From<K>, 
[src]

Divides one slice into two at an index.

See slice::split_at for more details.

pub fn split_at_mut(&mut self, mid: K) -> (&mut Self, &mut Self) where
    usize: From<K>, 
[src]

Divides one mutable slice into two at an index.

See slice::split_at_mut for more details.

pub fn split<F>(&self, pred: F) -> TiSliceRefMap<Split<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over subslices separated by elements that match pred. The matched element is not contained in the subslices.

See slice::split for more details.

pub fn split_mut<F>(
    &mut self,
    pred: F
) -> TiSliceMutMap<SplitMut<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over mutable subslices separated by elements that match pred. The matched element is not contained in the subslices.

See slice::split_mut for more details.

pub fn rsplit<F>(&self, pred: F) -> TiSliceRefMap<RSplit<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over subslices separated by elements that match pred, starting at the end of the slice and working backwards. The matched element is not contained in the subslices.

See slice::rsplit for more details.

pub fn rsplit_mut<F>(
    &mut self,
    pred: F
) -> TiSliceMutMap<RSplitMut<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over mutable subslices separated by elements that match pred, starting at the end of the slice and working backwards. The matched element is not contained in the subslices.

See slice::rsplit_mut for more details.

pub fn splitn<F>(
    &self,
    n: usize,
    pred: F
) -> TiSliceRefMap<SplitN<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices.

See slice::splitn for more details.

pub fn splitn_mut<F>(
    &mut self,
    n: usize,
    pred: F
) -> TiSliceMutMap<SplitNMut<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices.

See slice::splitn_mut for more details.

pub fn rsplitn<F>(
    &self,
    n: usize,
    pred: F
) -> TiSliceRefMap<RSplitN<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over subslices separated by elements that match pred limited to returning at most n items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices.

See slice::rsplitn for more details.

pub fn rsplitn_mut<F>(
    &mut self,
    n: usize,
    pred: F
) -> TiSliceMutMap<RSplitNMut<'_, V, F>, K, V> where
    F: FnMut(&V) -> bool
[src]

Returns an iterator over subslices separated by elements that match pred limited to returning at most n items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices.

See slice::rsplitn_mut for more details.

pub fn contains(&self, x: &V) -> bool where
    V: PartialEq
[src]

Returns true if the slice contains an element with the given value.

See slice::contains for more details.

pub fn starts_with(&self, needle: &Self) -> bool where
    V: PartialEq
[src]

Returns true if needle is a prefix of the slice.

See slice::starts_with for more details.

pub fn ends_with(&self, needle: &Self) -> bool where
    V: PartialEq
[src]

Returns true if needle is a suffix of the slice.

See slice::ends_with for more details.

Binary searches this sorted slice for a given element.

See slice::binary_search for more details.

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

Binary searches this sorted slice with a comparator function.

See slice::binary_search_by for more details.

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

Binary searches this sorted slice with a key extraction function.

See slice::binary_search_by_key for more details.

pub fn sort_unstable(&mut self) where
    V: Ord
[src]

Sorts the slice, but may not preserve the order of equal elements.

See slice::sort_unstable for more details.

pub fn sort_unstable_by<F>(&mut self, compare: F) where
    F: FnMut(&V, &V) -> Ordering
[src]

Sorts the slice with a comparator function, but may not preserve the order of equal elements.

See slice::sort_unstable_by for more details.

pub fn sort_unstable_by_key<K2, F>(&mut self, f: F) where
    F: FnMut(&V) -> K2,
    K2: Ord
[src]

Sorts the slice with a key extraction function, but may not preserve the order of equal elements.

See slice::sort_unstable_by_key for more details.

pub fn rotate_left(&mut self, mid: K) where
    usize: From<K>, 
[src]

Rotates the slice in-place such that the first mid elements of the slice move to the end while the last self.next_key() - mid elements move to the front. After calling rotate_left, the element previously at index mid will become the first element in the slice.

See slice::rotate_left for more details.

pub fn rotate_right(&mut self, k: K) where
    usize: From<K>, 
[src]

Rotates the slice in-place such that the first self.next_key() - k elements of the slice move to the end while the last k elements move to the front. After calling rotate_right, the element previously at index self.next_key() - k will become the first element in the slice.

See slice::rotate_right for more details.

pub fn clone_from_slice(&mut self, src: &Self) where
    V: Clone
[src]

Copies the elements from src into self.

See slice::clone_from_slice for more details.

pub fn copy_from_slice(&mut self, src: &Self) where
    V: Copy
[src]

Copies all elements from src into self, using a memcpy.

See slice::copy_from_slice for more details.

pub fn copy_within<R>(&mut self, src: R, dest: K) where
    R: TiRangeBounds<K>,
    V: Copy,
    usize: From<K>, 
[src]

Copies elements from one part of the slice to another part of itself, using a memmove.

See slice::copy_within for more details.

pub fn swap_with_slice(&mut self, other: &mut Self)[src]

Swaps all elements in self with those in other.

See slice::swap_with_slice for more details.

pub unsafe fn align_to<U>(&self) -> (&Self, &TiSlice<K, U>, &Self)[src]

Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.

See slice::align_to for more details.

pub unsafe fn align_to_mut<U>(
    &mut self
) -> (&mut Self, &mut TiSlice<K, U>, &mut Self)
[src]

Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.

See slice::align_to_mut for more details.

pub fn is_ascii(&self) -> bool[src]

Checks if all bytes in this slice are within the ASCII range.

See slice::is_ascii for more details.

pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool[src]

Checks that two slices are an ASCII case-insensitive match.

See slice::eq_ignore_ascii_case for more details.

pub fn make_ascii_uppercase(&mut self)[src]

Converts this slice to its ASCII upper case equivalent in-place.

See slice::make_ascii_uppercase for more details.

pub fn make_ascii_lowercase(&mut self)[src]

Converts this slice to its ASCII lower case equivalent in-place.

See slice::make_ascii_lowercase for more details.

pub fn sort(&mut self) where
    V: Ord
[src]

Sorts the slice.

See slice::sort for more details.

pub fn sort_by<F>(&mut self, compare: F) where
    F: FnMut(&V, &V) -> Ordering
[src]

Sorts the slice with a comparator function.

See slice::sort_by for more details.

pub fn sort_by_key<K2, F>(&mut self, f: F) where
    F: FnMut(&V) -> K2,
    K2: Ord
[src]

Sorts the slice with a key extraction function.

See slice::sort_by_key for more details.

pub fn sort_by_cached_key<K2, F>(&mut self, f: F) where
    F: FnMut(&V) -> K2,
    K2: Ord
[src]

Sorts the slice with a key extraction function.

See slice::sort_by_cached_key for more details.

pub fn to_vec(&self) -> TiVec<K, V> where
    V: Clone
[src]

Copies self into a new TiVec.

See slice::to_vec for more details.

pub fn repeat(&self, n: usize) -> TiVec<K, V> where
    V: Copy
[src]

Creates a vector by repeating a slice n times.

See slice::repeat for more details.

pub fn concat<Item: ?Sized>(&self) -> <Self as Concat<Item>>::Output where
    Self: Concat<Item>, 
[src]

Flattens a slice of T into a single value Self::Output.

See slice::concat for more details.

pub fn join<Separator>(
    &self,
    sep: Separator
) -> <Self as Join<Separator>>::Output where
    Self: Join<Separator>, 
[src]

Flattens a slice of T into a single value Self::Output, placing a given separator between each.

See slice::join for more details.

pub fn to_ascii_uppercase(&self) -> TiVec<K, u8>[src]

Returns a vector containing a copy of this slice where each byte is mapped to its ASCII upper case equivalent.

See slice::to_ascii_uppercase for more details.

pub fn to_ascii_lowercase(&self) -> TiVec<K, u8>[src]

Returns a vector containing a copy of this slice where each byte is mapped to its ASCII lower case equivalent.

See slice::to_ascii_lowercase for more details.

Trait Implementations

impl<K, V> AsMut<[V]> for TiVec<K, V>[src]

fn as_mut(&mut self) -> &mut [V][src]

Performs the conversion.

impl<K, V> AsMut<TiSlice<K, V>> for TiVec<K, V>[src]

fn as_mut(&mut self) -> &mut TiSlice<K, V>[src]

Performs the conversion.

impl<K, V> AsMut<TiVec<K, V>> for TiVec<K, V>[src]

fn as_mut(&mut self) -> &mut TiVec<K, V>[src]

Performs the conversion.

impl<K, V> AsMut<Vec<V, Global>> for TiVec<K, V>[src]

fn as_mut(&mut self) -> &mut Vec<V>[src]

Performs the conversion.

impl<K, V> AsRef<[V]> for TiVec<K, V>[src]

fn as_ref(&self) -> &[V][src]

Performs the conversion.

impl<K, V> AsRef<TiSlice<K, V>> for TiVec<K, V>[src]

fn as_ref(&self) -> &TiSlice<K, V>[src]

Performs the conversion.

impl<K, V> AsRef<TiVec<K, V>> for TiVec<K, V>[src]

fn as_ref(&self) -> &TiVec<K, V>[src]

Performs the conversion.

impl<K, V> AsRef<Vec<V, Global>> for TiVec<K, V>[src]

fn as_ref(&self) -> &Vec<V>[src]

Performs the conversion.

impl<K, V> Borrow<TiSlice<K, V>> for TiVec<K, V>[src]

fn borrow(&self) -> &TiSlice<K, V>[src]

Immutably borrows from an owned value. Read more

impl<K, V> BorrowMut<TiSlice<K, V>> for TiVec<K, V>[src]

fn borrow_mut(&mut self) -> &mut TiSlice<K, V>[src]

Mutably borrows from an owned value. Read more

impl<K, V> Clone for TiVec<K, V> where
    V: Clone
[src]

fn clone(&self) -> TiVec<K, V>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<K, V> Debug for TiVec<K, V> where
    K: Debug + From<usize>,
    V: Debug
[src]

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

Formats the value using the given formatter. Read more

impl<K, V> Default for TiVec<K, V>[src]

fn default() -> Self[src]

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

impl<K, V> Deref for TiVec<K, V>[src]

type Target = TiSlice<K, V>

The resulting type after dereferencing.

fn deref(&self) -> &TiSlice<K, V>[src]

Dereferences the value.

impl<K, V> DerefMut for TiVec<K, V>[src]

fn deref_mut(&mut self) -> &mut TiSlice<K, V>[src]

Mutably dereferences the value.

impl<'de, K, V: Deserialize<'de>> Deserialize<'de> for TiVec<K, V>[src]

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>[src]

Deserialize this value from the given Serde deserializer. Read more

impl<'a, K, V: 'a + Copy> Extend<&'a V> for TiVec<K, V>[src]

fn extend<I: IntoIterator<Item = &'a V>>(&mut self, iter: I)[src]

Extends a collection with the contents of an iterator. Read more

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

impl<K, V> Extend<V> for TiVec<K, V>[src]

fn extend<I: IntoIterator<Item = V>>(&mut self, iter: I)[src]

Extends a collection with the contents of an iterator. Read more

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

impl<K, V> From<Box<TiSlice<K, V>, Global>> for TiVec<K, V>[src]

fn from(s: Box<TiSlice<K, V>>) -> TiVec<K, V>[src]

Performs the conversion.

impl<K, V> From<Vec<V, Global>> for TiVec<K, V>[src]

fn from(vec: Vec<V>) -> Self[src]

Performs the conversion.

impl<K, V> FromIterator<V> for TiVec<K, V>[src]

fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self[src]

Creates a value from an iterator. Read more

impl<K, V> Hash for TiVec<K, V> where
    V: Hash
[src]

fn hash<H: Hasher>(&self, state: &mut H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<K, V> IntoIterator for TiVec<K, V>[src]

type Item = V

The type of the elements being iterated over.

type IntoIter = IntoIter<V>

Which kind of iterator are we turning this into?

fn into_iter(self) -> IntoIter<V>[src]

Creates an iterator from a value. Read more

impl<'a, K, V> IntoIterator for &'a TiVec<K, V>[src]

type Item = &'a V

The type of the elements being iterated over.

type IntoIter = Iter<'a, V>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Iter<'a, V>[src]

Creates an iterator from a value. Read more

impl<'a, K, V> IntoIterator for &'a mut TiVec<K, V>[src]

type Item = &'a mut V

The type of the elements being iterated over.

type IntoIter = IterMut<'a, V>

Which kind of iterator are we turning this into?

fn into_iter(self) -> IterMut<'a, V>[src]

Creates an iterator from a value. Read more

impl<K, V> Ord for TiVec<K, V> where
    V: Ord
[src]

fn cmp(&self, other: &TiVec<K, V>) -> Ordering[src]

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

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<'a, K, A, B> PartialEq<&'a TiSlice<K, B>> for TiVec<K, A> where
    A: PartialEq<B>, 
[src]

fn eq(&self, other: &&'a TiSlice<K, B>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a, K, A, B> PartialEq<&'a mut TiSlice<K, B>> for TiVec<K, A> where
    A: PartialEq<B>, 
[src]

fn eq(&self, other: &&'a mut TiSlice<K, B>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<K, A, B> PartialEq<TiVec<K, B>> for TiVec<K, A> where
    A: PartialEq<B>, 
[src]

fn eq(&self, other: &TiVec<K, B>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<K, V> PartialOrd<TiVec<K, V>> for TiVec<K, V> where
    V: PartialOrd<V>, 
[src]

fn partial_cmp(&self, other: &TiVec<K, V>) -> Option<Ordering>[src]

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<K, V: Serialize> Serialize for TiVec<K, V>[src]

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>[src]

Serialize this value into the given Serde serializer. Read more

impl<K, V> Eq for TiVec<K, V> where
    V: Eq
[src]

Auto Trait Implementations

impl<K, V> RefUnwindSafe for TiVec<K, V> where
    V: RefUnwindSafe

impl<K, V> Send for TiVec<K, V> where
    V: Send

impl<K, V> Sync for TiVec<K, V> where
    V: Sync

impl<K, V> Unpin for TiVec<K, V> where
    V: Unpin

impl<K, V> UnwindSafe for TiVec<K, V> where
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]