// PrimaryIndex.h // CSI 2131 Asst 2a by Naim R. El-Far (naim@discover.uottawa.ca) // CSI 2131 - Winter 2006 - Prof. L.M. Moura // File: PrimaryIndex.h // Desc: Header file for class PrimaryIndex which handles the primary index file #pragma once #include #include #include using namespace std; const int INDEX_RECORD_SIZE = 11; class PrimaryIndex { public: fstream indexFileStream; string indexFileName; int numberOfRecordsInIndex; PrimaryIndex(); PrimaryIndex(string); ~PrimaryIndex(); long int GetFilePointerPosition(); //Function that returns the value of tellg. Used because in some instances tellg's overloaded functions were not defined with use with some operators void ReadByRRN(long int, string&, long int&); //Given a RRN, read the record and store its student number and byte offset in the passed by-ref parameters void WriteByRRN(long int, string, long int); //Given a RRN, a student number, and offset in the data file, write the student number and offset in the appropriate RRN void ShiftIndexRecords(long int); //Starting at a given point, shift all records to the right by one void Insert(string, long int); //Insert at current file pointer location void Addition(string, long int); //Insertion sort of a given line from the data file and its offset in the data file into the index long int BinarySearch(string); //Searches the whole index by calling Search(long, long, string) };