//+----------------------------------------------------------------------+
//|								    DAPsim								 |
//| Dean Morrison												11/30/06 |
//| University of Florida												 |
//| Department of Electrical and Computer Engineering					 |
//+----------------------------------------------------------------------+
//| Description: DAPsim is a trace-driven simulator developed in C++ for |
//| the purpose of designing, testing, and evaluating demand prepaging 	 |
//| policies.  It currently implements my proposed concept of Dynamically|
//| Adaptive Prepaging, but may be modified to evaluate many other 		 |
//| policies.															 |
//|																		 |
//| Reuse Policy: Use of this software for personal or instructional	 |
//| purposes is granted without fee provided that the source bears a	 |
//| clear and complete citation.										 |
//+----------------------------------------------------------------------+

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <math.h>

#include "main.h"
#ifndef LRU_PAGEQ_H_
#include "LRU_pageQ.h"
#endif //LRU_PAGEQ_H_

using namespace std;

class UsedPageQ {
private:
	int size;
	int maxSize;
	int minSize;
	LRU_pageQ ResidentQ;
	LRU_pageQ NonResidentQ;
	int histogram[DEFAULT_MAX_MEM_SIZE];

public:
	UsedPageQ();

	void setMaxSize(int newMaxSize);
	void setMinSize(int newMinSize);

	int getSize(void);
	int getMaxSize(void);
	int getMinSize(void);

	bool referencePage(unsigned long int pageNumber);

	void addPage(unsigned long int newPage);

	void evictPage(void);
	void removeNonResidentPage(unsigned long int pageNumber);

	void printQueueEntries(void);

	void clearHistogram(void);
	void incHistogram(int index);
	int findHistogramIndex(unsigned long int pageNumber);
	void printHistogram(void);
	void decayHistogram(double decayValue);
	int getHistogramEntry(int index);

	bool pagePresentInResidentQ(unsigned long int pageNumber);
	bool pagePresentInNonResidentQ(unsigned long int pageNumber);

	long int getMRUPageNumber(void);
};