📄 gistentry.h
字号:
// -*- Mode: C++ -*-//--------------------------------------------------------------------// GiSTentry.h// -----------//// GiST - Generalized Search Tree // June 2001 release, Aalborg University// // This file is a revised version of a part of the original // libGiST release (version 0.9beta1) // Copyright (c) 1996, Regents of the University of California//#ifndef GISTENTRY_H#define GISTENTRY_H#include <string.h> // for memcpy#include "GiSTdefs.h"#include "GiSTpredicate.h"class GiSTnode;//------------------------------------------------// GiSTpenalty is the token returned by the Penalty method. We don't// just use doubles here because it can be useful to use more// complex Penalty comparisons (e.g. to support multivalued Penalties that// break ties in a single value).class GiSTpenalty{public: GiSTpenalty() : amount(0) {} GiSTpenalty(const double d): amount(d) {} virtual double operator = (const double d) { amount = d; return amount; } virtual int operator < (GiSTpenalty &p) { if (amount < p.amount) return(1); else return(0); } virtual ~GiSTpenalty() {}protected: double amount;};//------------------------------------------------// GiSTentry: a key/pointer pair inside a node.// The key is a pointer to a GiSTobject, which can be used to// point to just about anything you like.class GiSTentry : public GiSTobject{public: GiSTentry() : node(NULL), key(NULL), level(0) {} GiSTentry(GiSTpage ptr) : node(NULL), key(NULL), ptr(ptr) {} GiSTentry(const GiSTentry& e) : node(e.node), ptr(e.ptr), position(e.position), level(e.level) {} virtual ~GiSTentry() { if (key) delete key; } // The following methods must be overridden by descendant classes virtual GiSTpenalty* Penalty (const GiSTentry &key) const = 0; virtual int CompressedLength() const = 0; // length of compressed key#ifdef PRINTING_OBJECTS virtual void Print(ostream& os) const = 0;#endif virtual GiSTobject* Copy () const = 0; virtual void Compress (char *data) const = 0; virtual void Decompress(const char *data, int entry_len) = 0; // Support for a fixed number of different predetermined entry lengths virtual int Type () const { return 0; } virtual void SetType (int type) {} // If you have ordered keys, this can be overridden a la qsort's compare virtual int Compare(const GiSTentry& entry) const { return 0; } // Access to the protected info GiSTpage Ptr () const { return ptr; } void SetPtr(GiSTpage p) { ptr = p; } GiSTobject *Key () const { return key; } GiSTobjid IsA () const { return GISTENTRY_CLASS; } int IsLeaf () const { return level == 0; } int Level () const { return level; } void SetLevel(int l) { level = l; } void SetPosition(int pos) { position = pos; } int Position () const { return position; } GiSTnode* Node () const { return node; } void SetNode(GiSTnode *n) { node = n; }protected: GiSTnode* node; GiSTpage ptr; int position; int level; GiSTobject* key;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -