Trait Sortable

Source
pub trait Sortable {
    // Required methods
    fn swap(&mut self, i: usize, j: usize);
    fn compare(&self, i: usize, j: usize) -> Ordering;
}
Expand description

Sortable is defined for types that should be allowed to be sorted.

Required Methods§

Source

fn swap(&mut self, i: usize, j: usize)

exchanges the data at index i with the data at index j

Source

fn compare(&self, i: usize, j: usize) -> Ordering

compares the data at index i with the data at index j

Implementations on Foreign Types§

Source§

impl<S: Sortable, T: Sortable> Sortable for (S, T)

Tuples of sortable elements are sortable within their common range

Source§

fn swap(&mut self, i: usize, j: usize)

Source§

fn compare(&self, i: usize, j: usize) -> Ordering

Source§

impl<T: Ord> Sortable for [T]

Slices of ordered elements are sortable

Source§

fn swap(&mut self, i: usize, j: usize)

Source§

fn compare(&self, i: usize, j: usize) -> Ordering

Source§

impl<T: Ord> Sortable for Vec<T>

Vectors of ordered elements are sortable

Source§

fn swap(&mut self, i: usize, j: usize)

Source§

fn compare(&self, i: usize, j: usize) -> Ordering

Implementors§