Expand description
qutee is a small create which implements a quad tree.
use qutee::*;
// Create a new quadtree where the area's top left corner is at -10, -10, with a width and height of 20.
let mut tree = QuadTree::new_with_dyn_cap(Boundary::new((-10., -10.), 20., 20.), 5);
assert!(tree.insert_at((0.5, 0.1), "A").is_ok());
assert!(tree.insert_at((-1., 1.), "B").is_ok());
// This point is outside the tree
assert!(tree.insert_at((10.1, 5.), "C").is_err());
// Search elements inside a boundary. A boundary can also be defined as an area between two points.
let mut query = tree.query(Boundary::between_points((0.,0.),(1.,1.)));
assert_eq!(query.next(), Some(&"A"));
assert!(query.next().is_none());
// Get an iterator over all items
let mut iter = tree.iter();
assert_eq!(iter.next(), Some(&"A"));
assert_eq!(iter.next(), Some(&"B"));
assert!(iter.next().is_none());
Structs§
- A rectangular area
- A Capacity known at compile time
- A Capacity known at runtime
- Iterator over all items
- Iterator over all items and their coordinates
- A point in two dimensional space
- Parameter
- Query Iterator
- Query Iterator over items and their coordinates
Enums§
- Possible errors
Traits§
- Trait defining methods shared by all shapes
- This traits allows a type to be used with
qutee::QuadTree::insert
- This trait is required for coordinates