| 1 |
root |
1.1 |
/********************************************************************* |
| 2 |
|
|
* * |
| 3 |
|
|
* Copyright (c) 1997,1998, 1999 * |
| 4 |
|
|
* Multimedia DB Group and DEIS - CSITE-CNR, * |
| 5 |
|
|
* University of Bologna, Bologna, ITALY. * |
| 6 |
|
|
* * |
| 7 |
|
|
* All Rights Reserved. * |
| 8 |
|
|
* * |
| 9 |
|
|
* Permission to use, copy, and distribute this software and its * |
| 10 |
|
|
* documentation for NON-COMMERCIAL purposes and without fee is * |
| 11 |
|
|
* hereby granted provided that this copyright notice appears in * |
| 12 |
|
|
* all copies. * |
| 13 |
|
|
* * |
| 14 |
|
|
* THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE * |
| 15 |
|
|
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * |
| 16 |
|
|
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * |
| 17 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR * |
| 18 |
|
|
* SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * |
| 19 |
|
|
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * |
| 20 |
|
|
* DERIVATIVES. * |
| 21 |
|
|
* * |
| 22 |
|
|
*********************************************************************/ |
| 23 |
|
|
|
| 24 |
|
|
#ifndef MTCURSOR_H |
| 25 |
|
|
#define MTCURSOR_H |
| 26 |
|
|
|
| 27 |
|
|
#ifndef MAXDOUBLE |
| 28 |
|
|
#ifdef _WIN32 // for MAXDOUBLE |
| 29 |
|
|
#include <float.h> |
| 30 |
|
|
#define MAXDOUBLE DBL_MAX |
| 31 |
|
|
#else |
| 32 |
|
|
#include <values.h> |
| 33 |
|
|
#endif |
| 34 |
|
|
#endif |
| 35 |
|
|
#include "GiST.h" |
| 36 |
|
|
#include "list.h" |
| 37 |
|
|
|
| 38 |
|
|
class MT; |
| 39 |
|
|
class MTentry; |
| 40 |
|
|
class MTpred; |
| 41 |
|
|
|
| 42 |
|
|
class dst { // this class is used in the NN-search algorithm for the priority queue |
| 43 |
|
|
public: |
| 44 |
|
|
dst(): bound(0), d(MAXDOUBLE) {} |
| 45 |
root |
1.2 |
dst(GiSTpath p, double LB, double dist): bound(LB), d(dist), path(p) {} |
| 46 |
root |
1.1 |
|
| 47 |
|
|
double Bound() const { return bound; } |
| 48 |
|
|
double Dist() const { return d; } |
| 49 |
|
|
GiSTpath Path() { return path; } |
| 50 |
|
|
private: |
| 51 |
|
|
double bound; |
| 52 |
|
|
double d; |
| 53 |
|
|
GiSTpath path; |
| 54 |
|
|
}; |
| 55 |
|
|
|
| 56 |
|
|
int comparedst(dst *a, dst *b); |
| 57 |
|
|
int comparedst(dst& a, dst& b); |
| 58 |
|
|
|
| 59 |
|
|
class MTcursor { |
| 60 |
|
|
public: |
| 61 |
|
|
MTcursor(const MT& tree, const MTpred& query); |
| 62 |
|
|
MTentry *Next(); |
| 63 |
|
|
BOOL IsReady() const; |
| 64 |
|
|
double Bound() const; |
| 65 |
|
|
~MTcursor(); |
| 66 |
|
|
|
| 67 |
|
|
private: |
| 68 |
|
|
void FetchNode(); |
| 69 |
|
|
|
| 70 |
|
|
const MT& tree; |
| 71 |
|
|
list<MTentry *> results; |
| 72 |
|
|
list<dst *> queue; |
| 73 |
|
|
MTpred *query; |
| 74 |
|
|
}; |
| 75 |
|
|
|
| 76 |
|
|
#endif |