Began implementing Storage::RTree.
[aesalon.git] / src / storage / RTree.cpp
blob86d7267e321486c6023deef7a21e21df5c65ad30
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/storage/RTree.cpp
8 */
10 #include "storage/RTree.h"
12 namespace Storage {
14 template<typename Key, typename Value, int Dimensions, int Maximum, int Minimum>
15 RTree<Key, Value, Dimensions, Maximum, Minimum>::RTree() {
16 m_root = NULL;
19 template<typename Key, typename Value, int Dimensions, int Maximum, int Minimum>
20 void RTree<Key, Value, Dimensions, Maximum, Minimum>::search(
21 const RTree<Key, Value, Dimensions, Maximum, Minimum>::Bound &bound,
22 RTree<Key, Value, Dimensions, Maximum, Minimum>::SearchProcessor *processor) {
24 search(bound, m_root, processor);
27 template<typename Key, typename Value, int Dimensions, int Maximum, int Minimum>
28 void RTree<Key, Value, Dimensions, Maximum, Minimum>::search(
29 const RTree<Key, Value, Dimensions, Maximum, Minimum>::Bound &bound,
30 RTree<Key, Value, Dimensions, Maximum, Minimum>::Node *node,
31 RTree<Key, Value, Dimensions, Maximum, Minimum>::SearchProcessor *processor) {
33 if(node == NULL) return;
35 if(node->isLeaf()) {
36 for(int i = 0; i < node->branchCount(); i ++) {
37 Branch &branch = node->branch(i);
38 if(branch.bound.overlaps(bound)) processor->process(branch.bound, branch.value);
41 else {
42 for(int i = 0; i < node->branchCount(); i ++) {
43 Branch &branch = node->branch(i);
44 if(branch.bound.overlaps(bound)) search(bound, branch.node, processor);
51 } // namespace Storage