Crate qutee

Source
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§

Boundary
A rectangular area
ConstCap
A Capacity known at compile time
DynCap
A Capacity known at runtime
Iter
Iterator over all items
IterPoints
Iterator over all items and their coordinates
Point
A point in two dimensional space
QuadTree
Parameter
Query
Query Iterator
QueryPoints
Query Iterator over items and their coordinates

Enums§

QuadTreeError
Possible errors

Traits§

Area
Trait defining methods shared by all shapes
AsPoint
This traits allows a type to be used with qutee::QuadTree::insert
Coordinate
This trait is required for coordinates