/*
 * CSI2131 Winter 2005
 *
 * Assignment#2 Solution : The Index class
 *(Implements a simple index using a dynamic array)
 *
 * Shantanu Das 
 */

#ifndef INDEX_H
#define INDEX_H


#include <iostream>
#include <fstream>
using namespace std;

const int minsize = 50;

class Index {

	struct ind_item {  
		long key; 
		long offset; 
	};

private:

	struct ind_item *Array;			// Array containing the index
	unsigned int size;				// size of the array
	int last;						// index of the last entry in the index
	
	int resize(unsigned int sz);				// change the size to sz 

public:

	Index();					// Constructor
    virtual ~Index();			// Destructor
	int insert(long k,long ofs);		// method for inserting new entry into the index
										// ( returns -1 for error )
	long search(long k);			// search for the key k and return its offset
									// ( returns -1 for error )
	
};

#endif