[−][src]Struct sorted_vec::SortedVec
Forward sorted vector
Implementations
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]
pub fn drain<R>(&mut self, range: R) -> Drain<T> where
R: RangeBounds<usize>,
[src]
R: RangeBounds<usize>,
pub fn into_vec(self) -> Vec<T>
[src]
NOTE: to_vec() is a slice method that is accessible through deref, use this instead to avoid cloning
pub fn mutate_vec<F, O>(&mut self, f: F) -> O where
F: FnOnce(&mut Vec<T>) -> O,
[src]
F: FnOnce(&mut Vec<T>) -> O,
Apply a closure mutating the sorted vector and use sort_unstable()
to re-sort the mutated vector
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 as_ptr(&self) -> *const T
1.37.0[src]
Returns a raw pointer to the vector's buffer.
The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.
The caller must also ensure that the memory the pointer (non-transitively) points to
is never written to (except inside an UnsafeCell
) using this pointer or any pointer
derived from it. If you need to mutate the contents of the slice, use as_mut_ptr
.
Examples
let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } }
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 + Ord> Clone for SortedVec<T>
[src]
impl<T: Debug + Ord> Debug for SortedVec<T>
[src]
impl<T: Ord> Default for SortedVec<T>
[src]
impl<T: Ord> Deref for SortedVec<T>
[src]
impl<T: Eq + Ord> Eq for SortedVec<T>
[src]
impl<T: Ord> Extend<T> for SortedVec<T>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
[src]
impl<T: Ord + Hash> Hash for SortedVec<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord> Ord for SortedVec<T>
[src]
fn cmp(&self, other: &SortedVec<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq + Ord> PartialEq<SortedVec<T>> for SortedVec<T>
[src]
impl<T: PartialOrd + Ord> PartialOrd<SortedVec<T>> for SortedVec<T>
[src]
fn partial_cmp(&self, other: &SortedVec<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &SortedVec<T>) -> bool
[src]
fn le(&self, other: &SortedVec<T>) -> bool
[src]
fn gt(&self, other: &SortedVec<T>) -> bool
[src]
fn ge(&self, other: &SortedVec<T>) -> bool
[src]
impl<T: Ord> StructuralEq for SortedVec<T>
[src]
impl<T: Ord> StructuralPartialEq for SortedVec<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for SortedVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SortedVec<T> where
T: Send,
T: Send,
impl<T> Sync for SortedVec<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SortedVec<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SortedVec<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> 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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,