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
. It’s also useful to collate types like f32
and f64
which do not support Ord
. A FloatCollator
is provided for this purpose.
Enable the “complex” feature to provide support for collating Complex
numbers provided by
the num_complex
crate.
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.Functions
Compare the
left
and right
f32` values for collation.Compare the
left
and right
f32` values for collation.