commit | ae8992c66b2008e287e9d32527b4dd451ed5a1a0 | [log] [tgz] |
---|---|---|
author | Esad Hajdarevic <esad@esse.at> | Fri Mar 28 18:34:04 2014 +0100 |
committer | Esad Hajdarevic <esad@esse.at> | Wed Apr 02 07:27:31 2014 +0200 |
tree | 064f947f5f855ed291d33f71365ed4c9f4859032 |
Initial import
Kvad is a quadtree data structure implementation in C99, extracted from the Superpin clustering library.
void walk(double x, double y, void* payload, void* context) { printf("Found %s at %f,%f", payload, x, y); } kvad_tree* tree = kvad_tree_create(0, 0, 1000, 1000, 16 /* max number of levels */, 16 /* max points per level */); kvad_tree_insert(tree, 10, 10, "Place 1"); kvad_tree_insert(tree, 10, 10, "Place 2"); kvad_tree_insert(tree, 10, 10, "Place 3"); kvad_tree_find(tree, 5, 5, 10, 10, walk, NULL); // Find all points in (5,5)-(15,15) rectangle kvad_tree_release(tree);
To enable internal assertions and checks on supplied arguments, define KVAD_ASSERTS=1
.
If defined, the assertion macro Kvad uses internally will expand to a stdlib assert()
call that aborts the program if an inconstitent state is encountered. Use this in your debug builds.