From 192a114305b4fcb7b3bb2154426456a7846b12f7 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Sat, 9 Dec 2023 21:09:25 +0100 Subject: [PATCH] improve README and manifest metadata. --- Cargo.lock | 2 +- Cargo.toml | 14 +++++++++++++- README.md | 15 +++++++++++++-- src/identified_vec.rs | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68e6f2e..9fac2cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "identified_vec" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyerror", "maplit", diff --git a/Cargo.toml b/Cargo.toml index 5a377e7..64e4290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,21 @@ [package] name = "identified_vec" -version = "0.1.1" +version = "0.1.2" edition = "2021" +authors = ["Alexander Cyon "] description = "Like HashSet but retaining INSERTION order and without `Hash` requirement on the Element type." license = "MIT" +readme = "README.md" +repository = "https://github.com/Sajjon/identified_vec" +keywords = [ + "identified-vec", + "identifiable", + "vec", + "orderset", + "set", + "hashset", +] +categories = ["data-structures"] [dependencies] anyerror = "0.1.12" diff --git a/README.md b/README.md index fba90d6..fa84f2b 100644 --- a/README.md +++ b/README.md @@ -134,8 +134,19 @@ let numbers = IdentifiedVec::::new_identifying_element(|e| *e); ``` # Motivation -None of the std collections `BTreeSet` and `HashSet` retain insertion order, `Vec` retains insertion order, however, it allows for duplicates. So if you want a collection of unique elements (Set-like) that does retain insertion order, `IdentifiedVec` suits your needs. Even better, the elements does not need to be to impl `Hash` nor ` Ord``. + +None of the std collections `BTreeSet` and `HashSet` retain insertion order, `Vec` retains insertion order, however, it allows for duplicates. So if you want a collection of unique elements (Set-like) that does retain insertion order, `IdentifiedVec` suits your needs. Even better, the elements does not need to be to impl `Hash` nor ` Ord`. + +# Features + +## Serde + +The `IdentifiedVecOf` type (which `Element` impl `Identifiable` trait) is `serde::Serializable` and `serde::Deserializable` as `Vec`. + +```toml +identified_vec = { version = "0.1.2", features = ["serde"] } +``` ## Implementation Details -An identified vec consists of a `Vec` of `ID`s keeping insertion order and a `HashMap` of id-element pairs, for contsant time lookip of element given an ID. \ No newline at end of file +An identified vec consists of a `Vec` of `ID`s keeping insertion order and a `HashMap` of id-element pairs, for contsant time lookip of element given an ID. diff --git a/src/identified_vec.rs b/src/identified_vec.rs index 7506072..64c6117 100644 --- a/src/identified_vec.rs +++ b/src/identified_vec.rs @@ -414,7 +414,7 @@ where /// A read-only collection view for the elements contained in this array, as a `Vec`. /// - /// - Complexity: O(1) + /// - Complexity: O(n) #[inline] pub fn elements(&self) -> Vec<&Element> { let mut elements_ordered = Vec::<&Element>::new();