{"id":18942003,"url":"https://github.com/lucidfrontier45/threshold_dict","last_synced_at":"2025-04-15T21:30:56.797Z","repository":{"id":61475679,"uuid":"551838942","full_name":"lucidfrontier45/threshold_dict","owner":"lucidfrontier45","description":"A data structure to find smallest key that is larger than the query.","archived":false,"fork":false,"pushed_at":"2023-07-13T12:44:42.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-06T16:18:19.615Z","etag":null,"topics":["data-structures"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/threshold-dict","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/lucidfrontier45.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":"2022-10-15T07:44:27.000Z","updated_at":"2022-12-17T11:02:18.000Z","dependencies_parsed_at":"2022-10-18T16:15:43.634Z","dependency_job_id":null,"html_url":"https://github.com/lucidfrontier45/threshold_dict","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidfrontier45%2Fthreshold_dict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidfrontier45%2Fthreshold_dict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidfrontier45%2Fthreshold_dict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidfrontier45%2Fthreshold_dict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidfrontier45","download_url":"https://codeload.github.com/lucidfrontier45/threshold_dict/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223684906,"owners_count":17185737,"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"],"created_at":"2024-11-08T12:30:48.339Z","updated_at":"2024-11-08T12:31:38.053Z","avatar_url":"https://github.com/lucidfrontier45.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# threshold-dict\nA data structure to find smallest key that is larger than the query.\n\nSuppose we have a following weight dependent price table.\n\n```\nweight,price\n100,10\n200,15\n500,30\n```\n\nThe price is decided by the smallest entry whose `weight` key is greater than or equal to the query. \n\n*examples*\n\n- weight=90 -\u003e price=10\n- weight=100 -\u003e price=10\n- weight=250 -\u003e price=30\n- weight=600 -\u003e price=Not Found\n\n## Install\n\n```sh\ncargo add threshold_dict\n```\n\n## Usage\n\nA `ThresholdDict` can be created by passing kv pairs. If query is greater than all of the keys, None is returned.\n\n```rust\nlet kv_pairs = vec![(100, 10), (200, 15), (500, 30)];\nlet dict = ThresholdDict::from(kv_pairs);\n\nassert_eq!(dict.query(\u002690), Some(\u002610));\nassert_eq!(dict.query(600), None);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidfrontier45%2Fthreshold_dict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidfrontier45%2Fthreshold_dict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidfrontier45%2Fthreshold_dict/lists"}