{"id":17656414,"url":"https://github.com/darnir/capped_multiset","last_synced_at":"2025-03-30T09:43:58.456Z","repository":{"id":57530744,"uuid":"83951787","full_name":"darnir/capped_multiset","owner":"darnir","description":"A Multiset that can return a capped value on the elements","archived":false,"fork":false,"pushed_at":"2017-09-20T22:34:13.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T20:17:26.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darnir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-05T07:04:31.000Z","updated_at":"2017-03-05T07:04:55.000Z","dependencies_parsed_at":"2022-09-05T11:11:45.267Z","dependency_job_id":null,"html_url":"https://github.com/darnir/capped_multiset","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darnir%2Fcapped_multiset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darnir%2Fcapped_multiset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darnir%2Fcapped_multiset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darnir%2Fcapped_multiset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darnir","download_url":"https://codeload.github.com/darnir/capped_multiset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301954,"owners_count":20755512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-23T14:32:00.545Z","updated_at":"2025-03-30T09:43:58.438Z","avatar_url":"https://github.com/darnir.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/darnir/capped_multiset.svg?branch=master)](https://travis-ci.org/darnir/capped_multiset)\n[![Crates.io](https://img.shields.io/crates/v/capped_multiset.svg)](https://crates.io/crates/capped_multiset)\n[![Crates.io](https://img.shields.io/crates/l/capped_multiset.svg)](./LICENSE)\n[![Docs.rs](https://docs.rs/capped_multiset/badge.svg)](https://docs.rs/capped_multiset)\n\n# CappedMultiset\n\nA multiset is a datastructure which resembles a classic Set, except it allows duplicate\nelements for each key. For more information on Multisets, see:\n\n* [Wikipedia Entry](https://en.wikipedia.org/wiki/Multiset)\n* [C++ Multisets](http://en.cppreference.com/w/cpp/container/multiset)\n* [C++ Multiset Tutorial](http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm)\n* _Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19_\n\nThis crate implements a `CappedMultiset`. A `CappedMultiset` is a datastructure similar to a\nmultiset, except it can have a dynamically defined \"cap\" on the value of each key. When such a\ncap is defined, any operation to retrieve the value of an element of the set, the value\nreturned will be no greater than the \"cap\" on the multiset. This `cap` can be changed at\nruntime and does not affect the actual data stored in the Multiset. As a result, setting\n`cap = 1` or any other low value is not a lossy operation.\n\n## Installation\n\n```toml\n[dependencies]\ncapped_multiset = \"0.1\"\n```\n\n## Example\n\n```rust\nextern crate capped_multiset;\n\nuse capped_multiset::CappedMultiset;\n\nfn main() {\n    let set = vec![1, 2, 3, 4, 5];\n    let mut capped_set = CappedMultiset::new(set);\n    assert_eq!(capped_set.sum(), 15);\n    capped_set.set_cap(Some(1));\n    assert_eq!(capped_set.sum(), 5);\n    capped_set.set_cap(Some(2));\n    assert_eq!(capped_set.sum(), 9);\n}\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarnir%2Fcapped_multiset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarnir%2Fcapped_multiset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarnir%2Fcapped_multiset/lists"}