#bisect #collation

collate

Traits and a data structure to support collation and bisection

11 releases

0.1.10 Apr 30, 2021
0.1.9 Apr 28, 2021
0.1.1 Jan 18, 2021

#319 in Rust patterns

Download history 30/week @ 2021-10-05 16/week @ 2021-10-12 9/week @ 2021-10-19 10/week @ 2021-10-26 15/week @ 2021-11-02 12/week @ 2021-11-09 10/week @ 2021-11-16 16/week @ 2021-11-23 25/week @ 2021-11-30 34/week @ 2021-12-07 10/week @ 2021-12-14 12/week @ 2021-12-21 9/week @ 2021-12-28 9/week @ 2022-01-04 25/week @ 2022-01-11 48/week @ 2022-01-18

95 downloads per month
Used in 10 crates (4 directly)

Apache-2.0

19KB
489 lines

collate

Rust collation utilities

Example usage:

use collate::*;

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);

lib.rs:

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:

# use collate::*;
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);

No runtime deps

-`