[−][src]Struct safe_index::examples::basic::VarMap
Vector indexed by variable indexes.
Methods
impl<T> VarMap<T>
[src]
pub fn of(vec: Vec<T>) -> Self
[src]
Creates an empty map from an existing one.
pub fn new() -> Self
[src]
Creates an empty map.
pub fn with_capacity(capacity: usize) -> Self
[src]
Creates an empty map with some capacity.
pub fn len(&self) -> usize
[src]
Number of elements in the map.
pub fn capacity(&self) -> usize
[src]
Capacity of the map.
pub fn next_index(&self) -> VarIndex
[src]
The next free index (wrapped self.len()
).
pub fn last_index(&self) -> Option<VarIndex>
[src]
The last index in the map.
pub fn push(&mut self, elem: T) -> VarIndex
[src]
Pushes an element.
pub fn pop(&mut self) -> Option<T>
[src]
Pops an element.
pub fn clear(&mut self)
[src]
Clears a map.
pub fn iter(&self) -> Iter<T>
[src]
Iterates over the elements.
ⓘImportant traits for VarMapIter<&'a VarMap<T>>pub fn index_iter<'a>(&'a self) -> VarMapIter<&'a VarMap<T>> where
T: 'a,
[src]
T: 'a,
Iterates over the elements with the index.
ⓘImportant traits for VarMapIter<&'a VarMap<T>>pub fn index_iter_mut<'a>(&'a mut self) -> VarMapIter<IterMut<'a, T>> where
T: 'a,
[src]
T: 'a,
Iterates over the elements with the index, mutable version.
ⓘImportant traits for VarMapIter<&'a VarMap<T>>pub fn into_index_iter(self) -> VarMapIter<VarMap<T>>
[src]
Iterates over the elements with the index.
pub fn iter_mut(&mut self) -> IterMut<T>
[src]
Iterates over the elements (mutable version).
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity as much as possible.
pub fn swap(&mut self, a: VarIndex, b: VarIndex)
[src]
Swap from Vec
.
pub fn swap_remove(&mut self, idx: VarIndex) -> T
[src]
Swap remove from Vec
.
impl<T: Clone> VarMap<T>
[src]
Methods from Deref<Target = Vec<T>>
pub fn capacity(&self) -> usize
1.0.0[src]
Returns the number of elements the vector can hold without reallocating.
Examples
let vec: Vec<i32> = Vec::with_capacity(10); assert_eq!(vec.capacity(), 10);
pub fn as_slice(&self) -> &[T]
1.7.0[src]
Extracts a slice containing the entire vector.
Equivalent to &s[..]
.
Examples
use std::io::{self, Write}; let buffer = vec![1, 2, 3, 5, 8]; io::sink().write(buffer.as_slice()).unwrap();
pub fn len(&self) -> usize
1.0.0[src]
Returns the number of elements in the vector, also referred to as its 'length'.
Examples
let a = vec![1, 2, 3]; assert_eq!(a.len(), 3);
pub fn is_empty(&self) -> bool
1.0.0[src]
Returns true
if the vector contains no elements.
Examples
let mut v = Vec::new(); assert!(v.is_empty()); v.push(1); assert!(!v.is_empty());
Trait Implementations
impl<T: Clone> Clone for VarMap<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: PartialEq> PartialEq<VarMap<T>> for VarMap<T>
[src]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: PartialOrd> PartialOrd<VarMap<T>> for VarMap<T>
[src]
fn partial_cmp(&self, other: &VarMap<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &VarMap<T>) -> bool
[src]
fn le(&self, other: &VarMap<T>) -> bool
[src]
fn gt(&self, other: &VarMap<T>) -> bool
[src]
fn ge(&self, other: &VarMap<T>) -> bool
[src]
impl<T: Eq> Eq for VarMap<T>
[src]
impl<T: Ord> Ord for VarMap<T>
[src]
fn cmp(&self, other: &VarMap<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<T> IntoIterator for VarMap<T>
[src]
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]
impl<'a, T> IntoIterator for &'a VarMap<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>
[src]
impl<'a, T> IntoIterator for &'a mut VarMap<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, T>
[src]
impl<T> From<Vec<T>> for VarMap<T>
[src]
impl<T> Default for VarMap<T>
[src]
impl<T: Debug> Debug for VarMap<T>
[src]
impl<T> Deref for VarMap<T>
[src]
impl<T> Index<VarIndex> for VarMap<T>
[src]
impl<T> Index<Range<usize>> for VarMap<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &[T]
[src]
impl<T> Index<RangeInclusive<usize>> for VarMap<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeInclusive<usize>) -> &[T]
[src]
impl<T> Index<RangeFrom<usize>> for VarMap<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &[T]
[src]
impl<T> Index<RangeTo<usize>> for VarMap<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &[T]
[src]
impl<T> IndexMut<VarIndex> for VarMap<T>
[src]
impl<T> FromIterator<T> for VarMap<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
Auto Trait Implementations
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,