home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
cprog
/
btree.zip
/
BTREE.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-16
|
3KB
|
127 lines
// C++ B+Tree
// (c) 1990,1991 Larry A. Walker
// This source is proprietary information which cannot be distributed
// without written permission of Larry A. Walker
#ifndef BTREE_H
#define BTREE_H
#include "bfh.hpp"
class Btree : public BFHClass {
int index_fd; // open file
struct Trunk trunk; // btree info
int vector; // Hierarchy list position
int blocks_to_flush; // total hierarchy blocks
int ActiveHeight; // count of nodes in hierarchy
static struct HierarchyBlock * hierarchy_list;
struct KeyGroup * active_key; // the active key
struct KeyGroup * key_copy; // copy of the returned key
struct Node * active_node; // the active node
int key_position; // the active key's position
long left; // left address
// variable length compare function
int (*compare_funct)(union Key *,struct KeyGroup *,int);
int LocateExact(union Key *); // internal key locate
int LocateInsert(union Key *,int); // internal key locate
int Insert(struct KeyGroup *, int);// internal key insert
long save_right_interior_node; // temporary place holder for
// delete and combine
int past_exact_key; // signal that there was an exact key
int KeyGroupSize(struct KeyGroup *); // what is the key group size
struct KeyGroup *CopyKey(); // copy the active key into a user area
// ++++++ Low Level Hierarchy operations
int OpenHierarchy(); // --------- Create the Hierarchy
int FlushHierarchy(); // Flush the entire Hierarchy
int LoadHierarchyNode(long); // Load a single Hierarchy block
struct Node * Parent(); // return the parent
void OpenKeyNode(struct Node *);
int InsertNodeKeyGroup(struct KeyGroup *);
// insert a key at the current position
int InsertSpareKeyGroup(struct KeyGroup *,struct Node *);
// insert a key into the spare key group
int DeleteNodeKeyGroup(); // delete a key
long LeftAddress(); // return the left address
int IncrementPosition();
// increment the position to the next key
// return Success or fail if no more keys
// at the end of the node, we are actually looking left at the
// most far right position
void Rewind(); // first key in node
int Compare(union Key *); // routines to return comparison of key
// value to the KeyGroup key
int Currentkey (struct KeyGroup * );
// ++++++ Intermediate level operations
int Combine();
// combine with left node, if fail combine with right
int UnlinkNode();
// release an empty node
// ++++++ High level user interface operations
public:
Btree(char *, int = 0, int = UNDEF_KEY, int = 0, int = 0);
~Btree(){
}
Close();
int InstallCompare( int (*) (union Key *, struct KeyGroup *,int) );
int Locate(union Key *);
// operator overloads ------------
int operator += (struct KeyGroup *);
int operator -= (union Key *);
struct KeyGroup * operator ++(); // next, prefix only
struct KeyGroup * operator --(); // previous, prefix only
//--------------------------------
struct KeyGroup * First();
struct KeyGroup * Last();
struct KeyGroup * CurrentKey();
void Debug(struct Node * , int);
void DisplayHeader();
void DisplayKey(struct KeyGroup *);
void DUMP ();
void CHECK (int);
long ReportState(int);
long NodePosn();
};
#endif BTREE_H