I would like to have a sorted array which has an f64 as key and an f64 as value. I need to update, delete and insert to this array by finding the right key. I need to get the first 1000 sorted entries, and also the first entry. These operations must be fast.
By reading the documentation, I thought BTreeMap is good for me.
However, when I try to insert into it I got this error message:
the trait bound `f64: Ord` is not satisfied
the trait `Ord` is not implemented for `f64`rustcE0277
What is the recommended way to do this with Rust?
My code:
use std::collections::BTreeMap;
pub struct MyStruct {
pub map: BTreeMap<f64, f64>
}
impl MyStruct {
pub fn new() -> MyStruct {
MyStruct {
map: BTreeMap::new()
}
}
}
fn main() {
let mut my_struct = MyStruct::new();
my_struct.map.insert(1.0, 2.0);
}