Crates.io | heapp |
lib.rs | heapp |
version | 0.1.0 |
source | src |
created_at | 2021-08-03 13:28:34.640806 |
updated_at | 2021-08-03 13:28:34.640806 |
description | Some heap operations on slice |
homepage | |
repository | https://github.com/Jamyw7g/heapp |
max_upload_size | |
id | 430944 |
size | 40,567 |
Some heap operations on slice
The following examples show a quick example of some of the very basic functionality of heapp
.
use heapp::*;
fn main() {
let mut heap = vec![4, 7, 8, 3, 4, 90, 78, 67, 90];
heapify(&mut heap); // build a heap
heap.push(32);
heap_push(&mut heap); // push an element into the heap
heap_pop(&mut heap); // pop an element from the heap
let ele = heap.pop().unwrap();
heap_sort(&mut heap); // same as heap.sort(), but using heap sort algorithm
let res = n_smallest(&mut heap, 3); // res == [3, 4, 4]
}