// KeyList.h
// CSI 2131 Asst 2b by Naim R. El-Far (naim@discover.uottawa.ca)
// CSI 2131 - Winter 2006 - Prof. L.M. Moura

// File:	KeyList.h
// Desc:	Header file for class KeyList which handles the key list index file

#pragma once

#include <string>
#include <fstream>
using namespace std;

const KEY_LIST_RECORD_SIZE = 11;

class KeyList {
public:
	string		keyListFileName;
	fstream		keyListFileStream;
	long int	numberOfKeysInList;
	
	KeyList(); //Default constructor
	KeyList(string); //Filename constructor
	~KeyList(); //Destructor

	void Insert(string, long int); //Assuming the file pointer is placed in the write place, write the student number and list next value where the file pointer currently sits
	void WriteByRRN(long int, string, long int); //Given an RRN, a student number, and a list next value, write the tuple in the appropriate RRN position
	void UpdateListNext(long int, long int); //Given an RRN, change the list next value of that RRN to a given RRN
	void ReadByRRN(long int, string&, long int&); //Given an RRN, read the corresponding record and store its values in the given student number string and list next long int
	long int InsertIntoInvertedList(long int, string); //Given a head of an inverted list, insert the given student number into the list sorted by student number. This function return the list head in the case that you are inserting at the beginning of a list
	void IncrementNumberOfKeys();
	void PrintList(ostream&); //Given an output stream, print the index to that stream
};
