⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtentry.h

📁 此文件包含了在linux下实现tpr-tree索引的源代码
💻 H
字号:
// -*- Mode: C++ -*-//--------------------------------------------------------------------//      RTentry.h//      ---------//      Implements the entry of the tree node////      Classes declared://      RTpenalty, RTentry////      Inheritance hierarchy://      GiSTpenalty//        RTpenalty//      GiSTobject//        GiSTentry//          RTentry////      TPR-tree - Index for continuously moving objects//      July 2001 release, Aalborg University//#ifndef RTENTRY_H#define RTENTRY_H#include <string.h>#include <stdio.h>#include <math.h>#include <limits.h>#include <new.h>#include "GiSTentry.h"#include "rtkey.h"class RT;class RTpredicate;class RTnode;class RTentry;//-------------------------------------------------------------//   RTSortEntry -//   Skeleton of the structure used to store entries in sort arrays//   during bulk loading operations. The actual number of coordinates //   depends on the dimensionality and whether entry is a leaf-node//   entry or not. //struct RTsortEntry{   GiSTpage  pid;   RTcoord   coords[1];    // Saptial coordinates followed by coordinates of a velocity                            // vector and, if required by the bulkloading algotithm,                           // followed by the angles describing the direction of a                            // velocity vector and the absolute value of speed   // These accessor methods are provided for the leaf-node "sort-entry"   RTcoord&  Velocity      (int i) { return coords[Settings.GetDims() + i];     }   RTcoord&  VelocityAngle (int i) { return coords[Settings.GetDims() * 2 + i]; }   RTcoord&  AbsSpeed      ()      { return coords[Settings.GetDims() * 3 - 1]; }    // These accessor methods are provided for the level-node "sort-entry"   RTcoord&  Rcoord    (int d, int j) { return coords[2*d + j];               }    RTcoord&  Rvelocity (int d, int j) { return coords[2*Settings.GetDims() + 2*d + j]; }};// LEVELREC contains min and max values for all spatial and velocity coordinates#define SIZEOF_LEVELREC    (4 *sizeof(RTcoord) * Settings.GetDims() + sizeof(GiSTpage))// LEVCREC in adition to LEVELREC contains center spatial and velocity coordinates#define SIZEOF_LEVCREC     (6 *sizeof(RTcoord) * Settings.GetDims() + sizeof(GiSTpage))// LEVCPLUSREC in addition to LEVCREC contains center velocity angles and // center speed absolute value #define SIZEOF_LEVCPLUSREC (7 *sizeof(RTcoord) * Settings.GetDims() + sizeof(GiSTpage))// LEAFREC contains spatial and velocity coordinates of a moving point#define SIZEOF_LEAFREC     (2 *sizeof(RTcoord) * Settings.GetDims() + sizeof(GiSTpage))// PLUSREC in addition to LEAFREC contains velocity angles and speed absolute value #define SIZEOF_PLUSREC     (3 *sizeof(RTcoord) * Settings.GetDims() + sizeof(GiSTpage))//-------------------------------------------------------------//   RTpenalty - a vector of 4 doubles, to support three tie-breakers.//   See the Penalty method of RTentry descendants for more detail.class RTpenalty : public GiSTpenalty{public:   RTpenalty() :     insertee(NULL), insertedInto(NULL)       {         amount  = DBL_MIN;      // Meaning "undefined"               amount2 = DBL_MIN;         amount3 = DBL_MIN;      }   RTpenalty (const double d,              const RTentry* e1, const RTentry* e2) :      GiSTpenalty(d), amount2(DBL_MIN),      amount3(DBL_MIN),      insertee(e1), insertedInto(e2) {}   void SetEntries(const RTentry* e1, const RTentry* e2)      {         amount     = DBL_MIN;      // Meaning "undefined"               amount2    = DBL_MIN;         amount3    = DBL_MIN;         insertee     = e1;         insertedInto = e2;        }      void SetToMax() { amount = amount2 = amount3 = DBL_MAX; }   operator bool()        {         return amount == 0.0;      }   double operator = (const double d)      {         amount = d;          return(amount);      }      RTpenalty&  operator = (const RTpenalty &p)      {          amount       = p.amount;         amount2      = p.amount2;         amount3      = p.amount3;         insertee     = p.insertee;         insertedInto = p.insertedInto;                       return *this;      }   int operator < (GiSTpenalty &p);   int Definedness () const      {         if (amount  == DBL_MIN) return 0;         if (amount2 == DBL_MIN) return 1;         if (amount3 == DBL_MIN) return 2;         return 3;            }   double    amount2;   double    amount3;   const RTentry* insertee;      // The entry being inserted   const RTentry* insertedInto;  // The entry under which insertee is to be inserted};//-------------------------------------------------------------//    RTentry//class RTentry : public GiSTentry{public:   RTentry() : GiSTentry() { key = new RTkey; }   RTentry(const RTkey& k, const GiSTpage p) :      GiSTentry() { key = k.Copy();  ptr = p; }   RTentry(const RTentry& e) : GiSTentry(e) { key = e.key->Copy(); }    RTentry& operator= (const RTentry& e)      {         this->~RTentry();         return *new(this) RTentry(e);       }       GiSTobjid   IsA()  const { return RTENTRY_CLASS;      }   GiSTobject* Copy() const { return new RTentry(*this); }    virtual RTkey* CreateKey() const  { return new RTkey; }     void InitKey();          void SetKey(const RTkey* k);      int IsEqual(const GiSTobject& obj) const   { return Key().isEqual_2n(((RTentry&)obj).Key()); }    // Representation on the disk   //   int  CompressedLength() const;   void Compress        (char *data) const;   void Decompress(const char *data, int entry_len);   // SetValues and GetValues are used for bulk loading    //   void SetValues(const RTsortEntry* se);   void GetValues(RTsortEntry* se) const;     RTpenalty*    CreatePenalty() const {return new RTpenalty;}    // Penalty as defined in GiSTentry is not used, since    // GiSTnode::SearchMinPenalty is redefined in RTnode       //   GiSTpenalty*  Penalty      (const GiSTentry &key) const { return NULL; }   void          Penalty      (const GiSTentry &newEntry,                                GiSTpenalty& penalty,                                bool first = false) const;   void          RefinePenalty (RTpenalty& penalty) const;   const RTkey&  bbox () const { return Key(); }   RTtimeStamp RefTS() const { return Key().RefTS(); }   RTtimeStamp t2   () const { return Key().t2; }   void ComputeNaturalt2 ()  { Key().ComputeNaturalt2(); }   RTcoord     CoordT(int d, int j = 0, RTperiod p = 0) const    { return Key().CoordT(d, j, p); }    RTcoord     Coordtp(int d, int j = 0, RTtimeStamp t = 0) const    { return Key().Coordtp(d, j, t); }    RTcoord     CoordT_br(int d, int j = 0, RTperiod p = 0) const    { return Key().CoordT_br(d, j, p); }    RTcoord     Coordtp_br(int d, int j = 0, RTtimeStamp t = 0) const    { return Key().Coordtp_br(d, j, t); }    RTcoord     Coord(int d, int j = 0) const   { return Key().coords[d][j]; }   RTcoord     Speed(int d, int j = 0) const    { return Key().Speed(d, j); }   void SetRefTS   (RTtimeStamp d) { Key().SetRefTS(d);    }   void SetRefTS_br(RTtimeStamp d) { Key().SetRefTS_br(d); }   void Sett1      (RTtimeStamp d) { ((RTkey *)key)->t1 = d; }   void Sett2      (RTtimeStamp d) { Key().t2 = d; }   void SetCoord   (RTcoord k, int d, int j = 0)    { Key().coords[d][j] = k; }   void SetSpeed   (RTcoord k, int d, int j = 0)    { Key().coords[Settings.GetDims() + d][j] = k; }#ifdef PRINTING_OBJECTS   void Print(ostream& os) const;#endifprotected:   double OverlapArea(const RTkey &k) const;   RTkey &Key() const { return *(RTkey *)key; }};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -