5 releases

new 0.2.4 Jan 22, 2025
0.2.3 Jan 21, 2025
0.2.2 Dec 2, 2022
0.2.1 Nov 24, 2022
0.1.3 Nov 19, 2022

#700 in Data structures

Download history 11/week @ 2024-10-02 8/week @ 2024-12-11 59/week @ 2025-01-15

59 downloads per month
Used in time_priority_order_algor…

MIT license

31KB
578 lines

SortedList

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.

Benchmark Tests and Results

Usage

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]

Documentation

https://docs.rs/sortedlist-rs/latest/sortedlist_rs/

No runtime deps