Purse: Bag data structure implementation in Rust
Overview
Purse implements a bag in Rust, also known as a multi set, but that's a much more boring name. Bags are quite versatile structures, allowing storage of heterogeneous and non-unique collections of items, supporting different types and allowing duplicates.
Key Features
- Versatility: Can contain any item, with duplicates and different types.
- Mixed Collections: Ideal for applications requiring a mix of different types.
- Duplicate Handling: Allows multiple instances of the same item.
Installing
cargo add purse
Usage
use TypeId;
use Purse;
let mut purse = new;
purse.insert;
purse.insert;
assert!;
assert!;
assert_eq!;
// Get all of type.
let strings: = purse.get_all_of_type;
assert_eq!;
purse.insert;
purse.insert;
purse.insert;
assert!;
assert!;
assert!;
// Check the most common type.
assert_eq!;
// Clearing the bag.
purse.clear;
assert!;
// Add a few items again.
purse.insert;
purse.insert;
// Iteration over all elements in the bag
let mut nums: = vec!;
let mut strs: = vec!;
purse.iter.for_each;
assert_eq!;
assert_eq!;
Contributing
Contributions are welcome! Please follow the standard Rust conventions for pull requests.
License
This project is licensed under either of
- Apache License, Version 2.0 (licenses/Apache-2.0)
- MIT license (licenses/MIT)
at your option.
The SPDX license identifier for this project is MIT OR Apache-2.0.