// Bucket.h (You may modify, remove and/or add members) // This class is a simplification of the one given in the // textbook "File Structures" by Folk, Zoellick and Riccardi. // Bucket class holds a bucket in main memory #ifndef BUCKET_H #define BUCKET_H #include "Directory.h" using namespace std; class Directory; class Bucket { protected: // there are no public members, // access to Bucket members is only through class Directory Bucket ( Directory & dir, int maxKeys); int Insert (long key, int dataRecAddr); // may use "char *key" or "string & key" int Split(int); // split the bucket and redistribute keys int MaxKeySize; int NumKeys; int Index; int Curbuffer[2]; int BucketContent[10]; int Numlines; int NewRange (int & newStart, int & newEnd); // calculate the range in directory of new (split) bucket int Redistribute (); // redistribute keys between this and new bucket int Depth; // depth of the bucket // number of bits used in common by keys of this bucket Directory & Dir; // pointer to the directory that contains the bucket fstream BucketFile; // logical name for bucket file int BucketAddr; //address of this bucket in file // Index accessors int getIndex() const; void setIndex(int); // include here variable to hold the various (maxKeys) index records in this bucket friend class Directory; // Directory has access to its protected members }; #endif