Skip to content

Commit

Permalink
Prepare for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
dtwitty committed Feb 27, 2024
1 parent 4abaf31 commit 94a5779
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 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.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "multi_containers"
version = "0.1.4"
version = "0.2.0"
edition = "2021"
documentation = "https://docs.rs/multi_containers"
repository = "https://github.com/dtwitty/multi_containers"
license = "MIT"
description = "A library for containers with duplicate entries"
description = "Ergonomically work with multiple values per key"
keywords = ["multiset", "multimap"]
categories = ["data-structures"]
readme = "README.md"
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# Multi-Containers
# multi_containers

[![crates.io](https://img.shields.io/crates/v/multi_containers.svg)](https://crates.io/crates/multi_containers)
[![docs](https://docs.rs/multi_containers/badge.svg)](https://docs.rs/multi_containers)

This crate implements containers that can have duplicate values.
If you have ever written a `HashMap<K, HashSet<V>>`, this crate is for you.
This crate is unstable and its API is subject to change at any time until 1.0.0.

**This crate is unstable and its API is subject to change at any time until 1.0.0**.

This crate is comparable in spirit to these containers in other languages:
- Java's `Guava` library's `Multimap` and `Multiset` (which heavily inspired this crate).
- Python's `collections.defaultdict(set)` and `collections.Counter`.
- C++'s `std::(unordered_)mutlimap` and `std::(unordered_)multiset`.

## Usage
### Usage
The primary containers are `MultiMap` and `MultiSet`. See `examples.rs` for more examples.

### MultiMap
#### MultiMap
`MultiMap` is a wrapper around `Map<K, Set<V>>`.
You can either use the provided `HashMultiMap` or `BTreeMultiMap`, or provide your own types with `MultiMapBuilder`.
The API is similar to what you would expect from `HashMap<K, HashSet<V>>`, with some additional methods related to the multiple values.
Expand All @@ -31,7 +33,7 @@ assert_eq!(map.get("a").unwrap().len(), 2);
assert_eq!(map.get("b").unwrap().len(), 1);
```

### MultiSet
#### MultiSet
`MultiSet` is a wrapper around `Map<V, usize>`. It offers the semantics of a set, but allows for duplicate values.
It offers iterators over unique `(&V, usize)`, and non-unique `&V`.

Expand All @@ -45,9 +47,4 @@ assert_eq!(set.count(&1), 2);
assert_eq!(set.count(&2), 3);
```


## To-Do
- [ ] Add doctests and usage examples.
- [ ] Implement common traits like `Extend`. This is blocked on `impl_trait_in_assoc_type` being stabilized.
- [ ] Collect user feedback and improve the API before 1.0.0.
- [ ] Explore concurrency options.
License: MIT
8 changes: 8 additions & 0 deletions README.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# {{crate}}

[![crates.io](https://img.shields.io/crates/v/multi_containers.svg)](https://crates.io/crates/multi_containers)
[![docs](https://docs.rs/multi_containers/badge.svg)](https://docs.rs/multi_containers)

{{readme}}

License: {{license}}
10 changes: 2 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

//! This crate implements containers that can have duplicate values.
//! If you have ever written a `HashMap<K, HashSet<V>>`, this crate is for you.
//! This crate is unstable and its API is subject to change at any time until 1.0.0.
//!
//! **This crate is unstable and its API is subject to change at any time until 1.0.0**.
//!
//! This crate is comparable in spirit to these containers in other languages:
//! - Java's `Guava` library's `Multimap` and `Multiset` (which heavily inspired this crate).
Expand Down Expand Up @@ -42,13 +43,6 @@
//! assert_eq!(set.count(&1), 2);
//! assert_eq!(set.count(&2), 3);
//! ```
//!
//!
//! ## To-Do
//! - [ ] Add doctests and usage examples.
//! - [ ] Implement common traits like `Extend`. This is blocked on `impl_trait_in_assoc_type` being stabilized.
//! - [ ] Collect user feedback and improve the API before 1.0.0.
//! - [ ] Explore concurrency options.
/// Defines the `MultiMap` type.
pub mod multimap;
Expand Down

0 comments on commit 94a5779

Please sign in to comment.