Expand description
Defines a Collate
trait to standardize collation methods across data types. The provided
Collator
struct can be used to collate a collection of slices of type T
where T: Ord
.
Also provides bisect
(with a Range
), bisect_left
, and bisect_right
methods.
Collate
is useful for implementing a B-Tree, or to handle cases where a collator type is
more efficient than calling Ord::cmp
repeatedly, for example when collating localized strings
using rust_icu_ucol
.
Example:
let collator = Collator::default();
let collection = [
[1, 2, 3],
[2, 3, 4],
[3, 4, 5],
];
assert_eq!(collator.bisect_left(&collection, &[1]), 0);
assert_eq!(collator.bisect_right(&collection, &[1]), 1);
Structs
A generic collator for any type T: Ord
.
A range for use with the Collate
trait.
Traits
Defines methods to collate a collection of slices of type Value
, given a comparator.