Struct onevec::OneVec [−][src]
pub struct OneVec<T>(_);
A Vec<T>
wrapper with one-based indices allowing for memory layout optimization, e.g.
Option<NonZeroUsize>
is the same size as usize
(8 or 4 bytes on most platforms)
For detailed methods documentation, see Vec
.
Methods
impl<T> OneVec<T>
[src]
impl<T> OneVec<T>
pub fn new() -> OneVec<T>
[src]
pub fn new() -> OneVec<T>
Constructs a new, empty OneVec<T>
.
Does not allocate memory.
pub fn with_capacity(capacity: usize) -> OneVec<T>
[src]
pub fn with_capacity(capacity: usize) -> OneVec<T>
Constructs a new, empty OneVec
pub fn from_vec(vec: Vec<T>) -> OneVec<T>
[src]
pub fn from_vec(vec: Vec<T>) -> OneVec<T>
Creates a OneVec<T>
from Vec<T>
. This operation is a no-op.
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns the number of elements the vector can hold without reallocating.
pub fn reserve(&mut self, additional: usize)
[src]
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more elements
to be inserted in the given OneVec<T>
.
pub fn reserve_exact(&mut self, additional: usize)
[src]
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for exactly additional more elements
to be inserted in the given OneVec<T>
.
pub fn shrink_to_fit(&mut self)
[src]
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the vector as much as possible.
pub fn truncate(&mut self, len: usize)
[src]
pub fn truncate(&mut self, len: usize)
Shortens the vector, keeping the first len elements and dropping the rest.
pub fn as_slice(&self) -> &[T]
[src]
pub fn as_slice(&self) -> &[T]
Extracts a slice containing the entire vector.
pub fn as_mut_slice(&mut self) -> &mut [T]
[src]
pub fn as_mut_slice(&mut self) -> &mut [T]
Extracts a mutable slice of the entire vector.
pub fn into_vec(self) -> Vec<T>
[src]
pub fn into_vec(self) -> Vec<T>
Consumes the OneVec<T>
, returning the inner vector.
pub fn swap_remove(&mut self, index: NonZeroUsize) -> T
[src]
pub fn swap_remove(&mut self, index: NonZeroUsize) -> T
Removes an element from the vector and returns it.
pub fn insert(&mut self, index: NonZeroUsize, element: T)
[src]
pub fn insert(&mut self, index: NonZeroUsize, element: T)
Inserts an element at position index within the vector, shifting all elements after it to the right.
pub fn remove(&mut self, index: NonZeroUsize) -> T
[src]
pub fn remove(&mut self, index: NonZeroUsize) -> T
Removes and returns the element at position index within the vector, shifting all elements after it to the left.
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&T) -> bool,
[src]
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&T) -> bool,
Retains only the elements specified by the predicate.
pub fn dedup_by_key<F, K>(&mut self, key: F) where
F: FnMut(&mut T) -> K,
K: PartialEq,
[src]
pub fn dedup_by_key<F, K>(&mut self, key: F) where
F: FnMut(&mut T) -> K,
K: PartialEq,
Removes all but the first of consecutive elements in the vector that resolve to the same key.
pub fn dedup_by<F>(&mut self, same_bucket: F) where
F: FnMut(&mut T, &mut T) -> bool,
[src]
pub fn dedup_by<F>(&mut self, same_bucket: F) where
F: FnMut(&mut T, &mut T) -> bool,
Removes all but the first of consecutive elements in the vector satisfying a given equality relation.
pub fn push(&mut self, value: T)
[src]
pub fn push(&mut self, value: T)
Appends an element to the back of a collection.
pub fn pop(&mut self) -> Option<T>
[src]
pub fn pop(&mut self) -> Option<T>
Removes the last element from a vector and returns it, or None if it is empty.
pub fn append(&mut self, other: &mut OneVec<T>)
[src]
pub fn append(&mut self, other: &mut OneVec<T>)
Moves all the elements of other into Self, leaving other empty.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clears the vector, removing all values.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in the vector, also referred to as its 'length'.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true if the vector contains no elements.
pub fn split_off(&mut self, at: NonZeroUsize) -> OneVec<T>
[src]
pub fn split_off(&mut self, at: NonZeroUsize) -> OneVec<T>
Splits the collection into two at the given index.
Returns a newly allocated Self. self contains elements [0, at), and the returned Self contains elements [at, len).
pub fn iter(&self) -> Iter<T>
[src]
pub fn iter(&self) -> Iter<T>
Returns an iterator over the vector.
pub fn iter_mut(&mut self) -> IterMut<T>
[src]
pub fn iter_mut(&mut self) -> IterMut<T>
Returns an iterator that allows modifying each value.
Trait Implementations
impl<T: Clone> Clone for OneVec<T>
[src]
impl<T: Clone> Clone for OneVec<T>
fn clone(&self) -> OneVec<T>
[src]
fn clone(&self) -> OneVec<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Default> Default for OneVec<T>
[src]
impl<T: Default> Default for OneVec<T>
impl<T: Debug> Debug for OneVec<T>
[src]
impl<T: Debug> Debug for OneVec<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Eq> Eq for OneVec<T>
[src]
impl<T: Eq> Eq for OneVec<T>
impl<T: Hash> Hash for OneVec<T>
[src]
impl<T: Hash> Hash for OneVec<T>
fn hash<__HT: Hasher>(&self, state: &mut __HT)
[src]
fn hash<__HT: Hasher>(&self, state: &mut __HT)
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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: PartialEq> PartialEq for OneVec<T>
[src]
impl<T: PartialEq> PartialEq for OneVec<T>
fn eq(&self, other: &OneVec<T>) -> bool
[src]
fn eq(&self, other: &OneVec<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &OneVec<T>) -> bool
[src]
fn ne(&self, other: &OneVec<T>) -> bool
This method tests for !=
.
impl<T> IntoIterator for OneVec<T>
[src]
impl<T> IntoIterator for OneVec<T>
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<T>
[src]
fn into_iter(self) -> IntoIter<T>
Creates an iterator from a value. Read more
impl<T> Index<RangeFull> for OneVec<T>
[src]
impl<T> Index<RangeFull> for OneVec<T>
type Output = [T]
The returned type after indexing.
fn index(&self, _index: RangeFull) -> &[T]
[src]
fn index(&self, _index: RangeFull) -> &[T]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<RangeFull> for OneVec<T>
[src]
impl<T> IndexMut<RangeFull> for OneVec<T>
fn index_mut(&mut self, _index: RangeFull) -> &mut [T]
[src]
fn index_mut(&mut self, _index: RangeFull) -> &mut [T]
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<Range<NonZeroUsize>> for OneVec<T>
[src]
impl<T> Index<Range<NonZeroUsize>> for OneVec<T>
type Output = [T]
The returned type after indexing.
fn index(&self, index: Range<NonZeroUsize>) -> &[T]
[src]
fn index(&self, index: Range<NonZeroUsize>) -> &[T]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<Range<NonZeroUsize>> for OneVec<T>
[src]
impl<T> IndexMut<Range<NonZeroUsize>> for OneVec<T>
fn index_mut(&mut self, index: Range<NonZeroUsize>) -> &mut [T]
[src]
fn index_mut(&mut self, index: Range<NonZeroUsize>) -> &mut [T]
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<RangeInclusive<NonZeroUsize>> for OneVec<T>
[src]
impl<T> Index<RangeInclusive<NonZeroUsize>> for OneVec<T>
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeInclusive<NonZeroUsize>) -> &[T]
[src]
fn index(&self, index: RangeInclusive<NonZeroUsize>) -> &[T]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<RangeInclusive<NonZeroUsize>> for OneVec<T>
[src]
impl<T> IndexMut<RangeInclusive<NonZeroUsize>> for OneVec<T>
fn index_mut(&mut self, index: RangeInclusive<NonZeroUsize>) -> &mut [T]
[src]
fn index_mut(&mut self, index: RangeInclusive<NonZeroUsize>) -> &mut [T]
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<RangeTo<NonZeroUsize>> for OneVec<T>
[src]
impl<T> Index<RangeTo<NonZeroUsize>> for OneVec<T>
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeTo<NonZeroUsize>) -> &[T]
[src]
fn index(&self, index: RangeTo<NonZeroUsize>) -> &[T]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<RangeTo<NonZeroUsize>> for OneVec<T>
[src]
impl<T> IndexMut<RangeTo<NonZeroUsize>> for OneVec<T>
fn index_mut(&mut self, index: RangeTo<NonZeroUsize>) -> &mut [T]
[src]
fn index_mut(&mut self, index: RangeTo<NonZeroUsize>) -> &mut [T]
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<RangeToInclusive<NonZeroUsize>> for OneVec<T>
[src]
impl<T> Index<RangeToInclusive<NonZeroUsize>> for OneVec<T>
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeToInclusive<NonZeroUsize>) -> &[T]
[src]
fn index(&self, index: RangeToInclusive<NonZeroUsize>) -> &[T]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<RangeToInclusive<NonZeroUsize>> for OneVec<T>
[src]
impl<T> IndexMut<RangeToInclusive<NonZeroUsize>> for OneVec<T>
fn index_mut(&mut self, index: RangeToInclusive<NonZeroUsize>) -> &mut [T]
[src]
fn index_mut(&mut self, index: RangeToInclusive<NonZeroUsize>) -> &mut [T]
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<RangeFrom<NonZeroUsize>> for OneVec<T>
[src]
impl<T> Index<RangeFrom<NonZeroUsize>> for OneVec<T>
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeFrom<NonZeroUsize>) -> &[T]
[src]
fn index(&self, index: RangeFrom<NonZeroUsize>) -> &[T]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<RangeFrom<NonZeroUsize>> for OneVec<T>
[src]
impl<T> IndexMut<RangeFrom<NonZeroUsize>> for OneVec<T>
fn index_mut(&mut self, index: RangeFrom<NonZeroUsize>) -> &mut [T]
[src]
fn index_mut(&mut self, index: RangeFrom<NonZeroUsize>) -> &mut [T]
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<NonZeroUsize> for OneVec<T>
[src]
impl<T> Index<NonZeroUsize> for OneVec<T>
type Output = T
The returned type after indexing.
fn index(&self, index: NonZeroUsize) -> &T
[src]
fn index(&self, index: NonZeroUsize) -> &T
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<NonZeroUsize> for OneVec<T>
[src]
impl<T> IndexMut<NonZeroUsize> for OneVec<T>
fn index_mut(&mut self, index: NonZeroUsize) -> &mut T
[src]
fn index_mut(&mut self, index: NonZeroUsize) -> &mut T
Performs the mutable indexing (container[index]
) operation.