| Crates.io | sortedlist-rs |
| lib.rs | sortedlist-rs |
| version | 0.2.5 |
| created_at | 2022-11-18 05:33:41.956225+00 |
| updated_at | 2025-06-15 06:35:44.674331+00 |
| description | A fast sorted list data structure in rust. |
| homepage | |
| repository | https://github.com/nicku12345/sortedlist-rs |
| max_upload_size | |
| id | 717659 |
| size | 74,533 |
A fast sorted list data structure in rust, inspired by the python library Sorted Containers
This repository is a work in progress. See Usage and Documentation for available features.
use sortedlist_rs::SortedList;
let array = vec![90, 19, 25];
let mut sorted_list = SortedList::from(array);
println!("{:?}", sorted_list);
// [19, 25, 90]
sorted_list.insert(100);
sorted_list.insert(1);
sorted_list.insert(20);
println!("{:?}", sorted_list);
// [1, 19, 20, 25, 90, 100]
let x = sorted_list.remove(3);
assert_eq!(25, x);
// removed the 3-rd smallest (0-indexed) element.
assert_eq!(&20, sorted_list.kth_smallest(2));
assert_eq!(20, sorted_list[2]);
println!("{:?}", sorted_list);
// [1, 19, 20, 90, 100]