Struct sorted_list::SortedList [] [src]

pub struct SortedList<K: Ord, V: PartialEq> { /* fields omitted */ }

SortedList stores multiple (K, V) tuples ordered by K, then in the order of insertion for V. Implmented using two Vec this should be fast for in-order inserts and quite bad in the worst-case of reverse insertion order.

Example

use sorted_list::SortedList;

let mut list: SortedList<u32, u8> = SortedList::new();
list.insert(0, 0);
list.insert(1, 1);
list.insert(0, 2);

assert_eq!(
    list.iter().collect::<Vec<_>>(),
    vec![(&0, &0), (&0, &2), (&1, &1)]);

Methods

impl<K: Ord, V: PartialEq> SortedList<K, V>
[src]

Creates a new as small as possible SortedList

Returns the number of tuples

Returns true if the (key, value) did not exist in the sorted list before and it exists now, false otherwise.

Returns the values of a specific key as a slice

Iterate all stored tuples, keys in order, values in insertion order

Iterate over all keys, can contain duplicates

Iterate over all values

Returns the first (in insertion order) value of key

Returns the last (in insertion order) value of key

Trait Implementations

impl<K: Ord + Clone, V: PartialEq + Clone> Clone for SortedList<K, V>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<K: Ord, V: PartialEq> IntoIterator for SortedList<K, V>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<K: Clone + Ord, V: PartialEq> Extend<(K, V)> for SortedList<K, V>
[src]

Extends a collection with the contents of an iterator. Read more

impl<K: Ord + Debug, V: PartialEq + Debug> Debug for SortedList<K, V>
[src]

Formats the value using the given formatter.