push_trait/sorted.rs
1//! Traits for pushing data into a collection while retaining a sorted invariant.
2
3use base::CanPush;
4
5/// A trait for moving data into a collection while retaining a sorted invariant.
6///
7/// Unlike [`Push`], sorted pushes must take a logarithmic amount of time and space with respect to
8/// the length of the collection.
9///
10/// [`Push`]: ../base/trait.Push.html
11pub trait PushSorted<T>: CanPush<T> {
12 /// Moves the value into the collection, yielding the value that was pushed out, if any.
13 ///
14 /// This method should retain some sort of sorting invariant within the collection.
15 fn push_sorted(&mut self, val: T) -> Option<Self::PushedOut>;
16}