Crates.io | sorted-vec |
lib.rs | sorted-vec |
version | |
source | src |
created_at | 2019-03-19 12:57:48.103996 |
updated_at | 2024-10-24 23:44:21.039532 |
description | Create and maintain sorted vectors and vector-backed sets |
homepage | |
repository | https://gitlab.com/spearman/sorted-vec |
max_upload_size | |
id | 122465 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
sorted_vec
Create and maintain collections of sorted elements.
let mut v = SortedVec::new();
assert_eq!(v.insert (5), 0);
assert_eq!(v.insert (3), 0);
assert_eq!(v.insert (4), 1);
assert_eq!(v.insert (4), 1);
assert_eq!(v.len(), 4);
v.dedup();
assert_eq!(v.len(), 3);
assert_eq!(v.binary_search (&3), Ok (0));
assert_eq!(*SortedVec::from_unsorted (
vec![5, -10, 99, -11, 2, 17, 10]),
vec![-11, -10, 2, 5, 10, 17, 99]);
Also provides sorted set containers only containing unique elements.
serde
supportserde
de/serialization is an optional feature.
By default, deserializing an unsorted container is an error.
To sort on deserialization, tag the field with
#[serde(deserialize_with = "SortedVec::deserialize_unsorted")]
:
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
pub struct Foo {
#[serde(deserialize_with = "SortedVec::deserialize_unsorted")]
pub v : SortedVec <u64>
}