ordered_vec

Crates.ioordered_vec
lib.rsordered_vec
version0.2.0
sourcesrc
created_at2023-01-04 15:46:21.884231
updated_at2023-01-05 00:24:37.846268
descriptionA trait that ensures that elements in a vector are pushed in a sorted order (both ascending and descending).
homepage
repositoryhttps://github.com/bwintertkb/ordered_vec
max_upload_size
id750914
size13,991
Bartek Winter (bwintertkb)

documentation

https://docs.rs/ordered_vec/0.1.0/ordered_vec/

README

ordered_vec

This little library provides a trait that ensures elements in a vector are pushed in a sorted order, both ascending and descending.

Example

use ordered_vec::OrdVec;
fn main() {
	let mut values: Vec<i32> = Vec::new();
	values.push_ord_ascending(5);
	values.push_ord_ascending(3);
	values.push_ord_ascending(7);
	values.push_ord_ascending(1);
	assert_eq!(values, [1, 3, 5, 7]);

	let mut values: Vec<i32> = Vec::new();
	values.push_ord_descending(5);
	values.push_ord_descending(3);
	values.push_ord_descending(7);
	values.push_ord_descending(1);
	assert_eq!(values, [7, 5, 3, 1]);
}

License

This library is licensed under MIT and Apache-2.0.

Commit count: 7

cargo fmt