[][src]Struct sortedvec::example::ExampleSortedVec

pub struct ExampleSortedVec { /* fields omitted */ }

Sorted vector type that provides quick access to Ts through Ks.

Methods

impl ExampleSortedVec
[src]

pub fn find(&self, key: &K) -> Option<&T>
[src]

Tries to find an element in the collection with the given key. It has logarithmic worst case time complexity.

pub fn contains(&self, key: &K) -> bool
[src]

Checks whether there is a value with that key in the collection. This is done in O(log(n)) time.

pub fn remove(&mut self, key: &K) -> Option<T>
[src]

Removes and returns a single value from the collection with the given key, if it exists. This operation has linear worst-case time complexity.

pub fn insert(&mut self, val: T)
[src]

Inserts a new value into the collection, maintaining the internal order invariant. This is an O(n) operation.

pub fn split_off(&mut self, at: usize) -> Self
[src]

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).

Note that the capacity of self does not change.

Panics

Panics if at > len.

pub fn dedup(&mut self)
[src]

Removes all elements but one that resolve to the same key.

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

Removes and returns the greatest element with the respect to the generated keys. An O(1) operation.

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 From<Vec<T>> for ExampleSortedVec
[src]

impl IntoIterator for ExampleSortedVec
[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?

impl Into<Vec<T>> for ExampleSortedVec
[src]

impl Extend<T> for ExampleSortedVec
[src]

impl Default for ExampleSortedVec
[src]

impl AsRef<[T]> for ExampleSortedVec
[src]

impl AsRef<Vec<T>> for ExampleSortedVec
[src]

impl Clone for ExampleSortedVec
[src]

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

Performs copy-assignment from source. Read more

impl Debug for ExampleSortedVec
[src]

impl Deref for ExampleSortedVec
[src]

type Target = Vec<T>

The resulting type after dereferencing.

impl FromIterator<T> for ExampleSortedVec
[src]

impl Borrow<[T]> for ExampleSortedVec
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From for T
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

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

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

type Owned = T

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

type Error = !

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

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.

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