push-trait 0.6.0

Push trait for collectons.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Traits for pushing data into a collection while retaining a sorted invariant.

use base::CanPush;

/// 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.
///
/// [`Push`]: ../base/trait.Push.html
pub trait PushSorted<T>: CanPush<T> {
    /// 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.
    fn push_sorted(&mut self, val: T) -> Option<Self::PushedOut>;
}