// SecondaryIndex.h // CSI 2131 Asst 2b by Naim R. El-Far (naim@discover.uottawa.ca) // CSI 2131 - Winter 2006 - Prof. L.M. Moura // File: SecondaryIndex.h // Desc: Header file for class SecondaryIndex which handles the secondary index file #pragma once #include #include #include "KeyList.h" using namespace std; const int SEC_INDEX_RECORD_SIZE = 24; class SecondaryIndex { public: string indexFileName; fstream indexFileStream; long int numberOfRecordsInIndex; KeyList* pKeyList; SecondaryIndex(); //Default constructor SecondaryIndex(string, string); //Filename constructor: given an index file name and a key list file name, use those files to store the sec index using inverted lists ~SecondaryIndex(); //Destructor void SpaceFormatLastName(string&); //Given a last name, format it so that it fills a 20 character field void CapitalizeLastName(string&); //Given a last name, change its case to all upper void Insert(string, long int); //Given a last name and a list start RRN, insert the tuple in the index file void ReadByRRN(long int, string&, long int&); //Given a RRN and a string and long int to store the last name and list start values in, read the RRN void WriteByRRN(long int, string, long int); //Given a RRN and a last name and list start values, store them in the index void ShiftIndexRecords(long int); //Given a RRN, shift all the records to the right by one starting at this record void Addition(string, string, long int); //Add a record to the secondary index given the last name, student number, and the byte offset void PrintIndex(ostream&); //Given an output stream, print the index to that stream long int BinarySearch(string); //Given a last name, return the list start corresponding to that last name in the sec index };