Trait PushSorted

Source
pub trait PushSorted<T>: CanPush<T> {
    // Required method
    fn push_sorted(&mut self, val: T) -> Option<Self::PushedOut>;
}
Expand description

A trait for moving data into a collection while retaining a sorted invariant.

Unlike Push, sorted pushes must take a logarithmic amount of time and space with respect to the length of the collection.

Required Methods§

Source

fn push_sorted(&mut self, val: T) -> Option<Self::PushedOut>

Moves the value into the collection, yielding the value that was pushed out, if any.

This method should retain some sort of sorting invariant within the collection.

Implementations on Foreign Types§

Source§

impl<K: Ord, V> PushSorted<(K, V)> for BTreeMap<K, V>

Source§

fn push_sorted(&mut self, (key, val): (K, V)) -> Option<Self::PushedOut>

Source§

impl<T: Ord> PushSorted<T> for BinaryHeap<T>

Source§

fn push_sorted(&mut self, val: T) -> Option<Self::PushedOut>

Source§

impl<T: Ord> PushSorted<T> for BTreeSet<T>

Source§

fn push_sorted(&mut self, val: T) -> Option<Self::PushedOut>

Implementors§