[−][src]Struct sorted_vec::SortedVec
Forward sorted vector
Methods
impl<T: Ord> SortedVec<T>
[src]
pub fn new() -> Self
[src]
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn from_unsorted(vec: Vec<T>) -> Self
[src]
Uses sort_unstable()
to sort in place.
pub fn insert(&mut self, element: T) -> Result<usize, usize>
[src]
Insert an element into sorted position, returning the order index at which it was placed.
If the element was already present, the order index is returned as an
Err
, otherwise it is returned with Ok
.
pub fn remove_item(&mut self, item: &T) -> Option<T>
[src]
pub fn remove_index(&mut self, index: usize) -> T
[src]
Panics if index is out of bounds
pub fn pop(&mut self) -> Option<T>
[src]
pub fn clear(&mut self)
[src]
pub fn dedup(&mut self)
[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: PartialEq + Ord> PartialEq<SortedVec<T>> for SortedVec<T>
[src]
impl<T: Ord> Default for SortedVec<T>
[src]
impl<T: Clone + Ord> Clone for SortedVec<T>
[src]
fn clone(&self) -> SortedVec<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug + Ord> Debug for SortedVec<T>
[src]
impl<T: Ord> Deref for SortedVec<T>
[src]
Auto Trait Implementations
Blanket Implementations
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> From for T
[src]
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> 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,