Skip to content

Commit

Permalink
improve README and manifest metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajjon committed Dec 9, 2023
1 parent 0dbfb69 commit 192a114
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
[package]
name = "identified_vec"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Alexander Cyon <[email protected]>"]
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"
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,19 @@ let numbers = IdentifiedVec::<u32, u32>::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.
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.
2 changes: 1 addition & 1 deletion src/identified_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ where

/// A read-only collection view for the elements contained in this array, as a `Vec<Elements>`.
///
/// - Complexity: O(1)
/// - Complexity: O(n)
#[inline]
pub fn elements(&self) -> Vec<&Element> {
let mut elements_ordered = Vec::<&Element>::new();
Expand Down

0 comments on commit 192a114

Please sign in to comment.