use crate::map::Map; use corundum::default::*; use std::collections::BTreeMap; type P = Allocator; pub struct RTree { btree: BTreeMap, } impl RTree { fn self_mut(&self) -> &mut Self { unsafe { &mut *(self as *const Self as *mut Self) } } } impl Map for RTree where K: std::cmp::Ord, { fn clear(&self) { self.self_mut().btree.clear(); } fn insert(&self, key: K, val: V) { self.self_mut().btree.insert(key, val); } fn remove(&self, key: K) { self.self_mut().btree.remove(&key); } fn is_empty(&self) -> bool { self.btree.is_empty() } fn foreach bool>(&self, f: F) -> bool { for (k, v) in &self.btree { f(k, v); } true } fn lookup(&self, key: K) -> bool { self.btree.get(&key).is_some() } } impl Default for RTree { fn default() -> Self { Self { btree: BTreeMap::new(), } } }