{"id":16701519,"url":"https://github.com/vitorenesduarte/threshold-rs","last_synced_at":"2025-04-10T04:11:54.372Z","repository":{"id":57669725,"uuid":"174320611","full_name":"vitorenesduarte/threshold-rs","owner":"vitorenesduarte","description":"Threshold data structures in Rust!","archived":false,"fork":false,"pushed_at":"2021-04-03T11:22:19.000Z","size":223,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T05:34:43.476Z","etag":null,"topics":["data-structures","rust","threshold","vector-clock"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitorenesduarte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T10:12:17.000Z","updated_at":"2022-11-23T16:23:33.000Z","dependencies_parsed_at":"2022-09-26T20:40:35.741Z","dependency_job_id":null,"html_url":"https://github.com/vitorenesduarte/threshold-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorenesduarte%2Fthreshold-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorenesduarte%2Fthreshold-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorenesduarte%2Fthreshold-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorenesduarte%2Fthreshold-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitorenesduarte","download_url":"https://codeload.github.com/vitorenesduarte/threshold-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154994,"owners_count":21056543,"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":["data-structures","rust","threshold","vector-clock"],"created_at":"2024-10-12T18:44:24.495Z","updated_at":"2025-04-10T04:11:54.306Z","avatar_url":"https://github.com/vitorenesduarte.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![crates.io](https://img.shields.io/crates/v/threshold.svg)](https://crates.io/crates/threshold)\n[![docs.rs](https://docs.rs/threshold/badge.svg)](https://docs.rs/threshold)\n[![Build Status](https://travis-ci.org/vitorenesduarte/threshold-rs.svg?branch=master)](https://travis-ci.org/vitorenesduarte/threshold-rs)\n[![Coverage Status](https://coveralls.io/repos/github/vitorenesduarte/threshold-rs/badge.svg)](https://coveralls.io/github/vitorenesduarte/threshold-rs)\n\n### `threshold-rs`: threshold data structures in Rust!\n\n#### Example\nAssume multiset `X` is `{10: 1, 8: 2, 6: 3, 5: 1}`.\nThis means that event `10` was seen once, event `8` twice, and so on.\n\nAssume that these events come from vector clocks, and thus seeing event 10 means seeing all events from 1 to 10.\n\nIf, for example, we want the event that was seen at least 4 times (i.e. our [threshold](https://vitorenes.org/post/2018/11/threshold-union/) is 4), we should get event `6`.\n    \nAssume `threshold(u64, X) -\u003e Option\u003cu64\u003e` where the first argument is the threshold desired and the output the event that passes the threshold (in case there's one). Then:\n- `threshold(1, X) = Some(10)`\n- `threshold(2, X) = Some(8)`\n- `threshold(3, X) = Some(8)`\n- `threshold(4, X) = Some(6)`\n- `threshold(7, X) = Some(5)`\n- `threshold(8, X) = None`\n\n#### Code Example\n```rust\nuse threshold::{clock, *};\n\nlet vclock_0 = clock::vclock_from_seqs(vec![10, 5, 5]);\nlet vclock_1 = clock::vclock_from_seqs(vec![8, 10, 6]);\nlet vclock_2 = clock::vclock_from_seqs(vec![9, 8, 7]);\n\nlet mut tclock = TClock::new();\ntclock.add(vclock_0);\ntclock.add(vclock_1);\ntclock.add(vclock_2);\n\nlet vclock_t1 = clock::vclock_from_seqs(vec![10, 10, 7]);\nlet vclock_t2 = clock::vclock_from_seqs(vec![9, 8, 6]);\nlet vclock_t3 = clock::vclock_from_seqs(vec![8, 5, 5]);\n\nassert_eq!(tclock.threshold_union(1), vclock_t1);\nassert_eq!(tclock.threshold_union(2), vclock_t2);\nassert_eq!(tclock.threshold_union(3), vclock_t3);\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorenesduarte%2Fthreshold-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitorenesduarte%2Fthreshold-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorenesduarte%2Fthreshold-rs/lists"}