GiSTlist<MTentry *> MT::RangeSearch (const MTquery& query, int *pages) { GiSTpath path; path.MakeRoot (); MTnode *root = (MTnode *) ReadNode (path); GiSTlist<MTentry *> list = root->RangeSearch(query, pages); delete root; return list; }
GiSTlist<MTentry *> MTnode::RangeSearch(const MTquery &query) { GiSTlist<MTentry *> result; if(IsLeaf()) for(int i=0; i<NumEntries(); i++) { MTentry *e=(MTentry *)(*this)[i].Ptr()->Copy(); MTquery *q=(MTquery *)query.Copy(); if(q->Consistent(*e)) { // object qualifies e->setmaxradius(q->Grade()); result.Append(e); } else delete e; delete q; } else for(int i=0; i<NumEntries(); i++) { MTentry *e=(MTentry *)(*this)[i].Ptr(); MTquery *q=(MTquery *)query.Copy(); if(q->Consistent(*e)) { // sub-tree not excluded GiSTpath childpath=Path(); MTnode *child; GiSTlist<MTentry *>list; childpath.MakeChild(e->Ptr()); child=(MTnode *)((MT *)Tree())->ReadNode(childpath); list=child->RangeSearch(*q); // recurse the search while(!list.IsEmpty()) result.Append(list.RemoveFront()); delete child; } delete q; } return result; }
GiSTlist<MTentry *> MTnode::RangeSearch (const MTquery &query) { GiSTlist<MTentry *> results; if (IsLeaf()) { for (int i=0; i<NumEntries(); i++) { MTentry *entry = (MTentry *) (*this)[i].Ptr()->Copy(); MTquery *newQuery = (MTquery *) query.Copy(); if (newQuery->Consistent(*entry)) { // object qualifies entry->SetMaxRadius(newQuery->Grade()); results.Append (entry); } else { delete entry; } delete newQuery; } } else { for (int i=0; i<NumEntries(); i++) { MTentry *entry = (MTentry *) (*this)[i].Ptr(); MTquery *newQuery = (MTquery *) query.Copy(); if (newQuery->Consistent(*entry)) { // sub-tree included GiSTpath childPath = Path (); childPath.MakeChild (entry->Ptr()); MTnode *childNode = (MTnode *) ((MT *)Tree())->ReadNode(childPath); GiSTlist<MTentry *> childResults = childNode->RangeSearch(*newQuery); // recurse the search while (!childResults.IsEmpty()) { results.Append (childResults.RemoveFront()); } delete childNode; } delete newQuery; } } return results; }