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

📄 ttree.h

📁 一个不错的fastdb使用例子
💻 H
字号:
//-< TTREE.CPP >-----------------------------------------------------*--------*
// FastDB                    Version 1.0         (c) 1999  GARRET    *     ?  *
// (Main Memory Database Management System)                          *   /\|  *
//                                                                   *  /  \  *
//                          Created:     20-Nov-98    K.A. Knizhnik  * / [] \ *
//                          Last update: 10-Dec-98    K.A. Knizhnik  * GARRET *
//-------------------------------------------------------------------*--------*
// T-Tree interface
//-------------------------------------------------------------------*--------*

#ifndef __TTREE_H__
#define __TTREE_H__

class FASTDB_DLL_ENTRY dbTtreeNode
{
  enum {
    pageSize = 125,
    minItems = pageSize - 2 // minimal number of items in internal node
  };

public:
  oid_t left;
  oid_t right;
  int1  balance;
  nat2  nItems;
  oid_t item[pageSize];

  static oid_t allocate(dbDatabase* db, oid_t recordId);

  static bool  insert(dbDatabase* db, oid_t& nodeId, oid_t recordId,
                      void* key, int type, int sizeofType, dbUDTComparator comparator, int offs);

  static int   remove
    (dbDatabase* db, oid_t& nodeId, oid_t recordId,
     void* key, int type, int sizeofType, dbUDTComparator comparator, int offs);

  static int   balanceRightBranch(dbDatabase* db, oid_t& nodeId);

  static int   balanceLeftBranch(dbDatabase* db, oid_t& nodeId);

  static void  purge(dbDatabase* db, oid_t nodeId);

  bool find(dbDatabase* db, dbSearchContext& sc);

  bool traverseForward(dbDatabase* db,dbAnyCursor* cursor);

  bool traverseBackward(dbDatabase* db, dbAnyCursor* cursor);

  bool traverseForward(dbDatabase* db,dbAnyCursor* cursor,dbExprNode* cond);

  bool traverseBackward(dbDatabase* db,dbAnyCursor* cursor,dbExprNode* cond);
};

class FASTDB_DLL_ENTRY dbTtree
{

protected:
  oid_t root;

public:
  static oid_t allocate(dbDatabase* db);
  static void  find(dbDatabase* db, oid_t treeId, dbSearchContext& sc);
  static void  insert(dbDatabase* db, oid_t treeId, oid_t recordId,
                      int type, int sizeofType, dbUDTComparator comparator, int offs);

  static void  remove
    (dbDatabase* db, oid_t treeId, oid_t recordId,
     int type, int sizeofType, dbUDTComparator comparator, int offs);

  static void  drop(dbDatabase* db, oid_t treeId);

  static void  purge(dbDatabase* db, oid_t treeId);

  static void  traverseForward(dbDatabase* db, oid_t treeId,
                               dbAnyCursor* cursor);

  static void  traverseBackward(dbDatabase* db, oid_t treeId,
                                dbAnyCursor* cursor);

  static void  traverseForward(dbDatabase* db, oid_t treeId,
                               dbAnyCursor* cursor, dbExprNode* condition);

  static void  traverseBackward(dbDatabase* db, oid_t treeId,
                                dbAnyCursor* cursor, dbExprNode* condition);
};


#endif

⌨️ 快捷键说明

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