-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLRU_Cache.cpp
39 lines (37 loc) · 1.12 KB
/
LRU_Cache.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "Doubly_List.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
long long int n,i;
string s;
Doubly_List<string>LRU_Cache_1; //LRU Cache for String data type
LRU_Cache_1.Set_Capacity(3);
for(i=0;i<7;i++)
{
cout<<"Enter string data: \n";
cin>>s;
LRU_Cache_1.Insert(s);
}
cout<<"LRU_Cache data: \n";
LRU_Cache_1.Print();
cout<<"\n";
cout<<"Number of Page Faults : "<<LRU_Cache_1.Page_Faults<<"\n";
//................................................................................................................................
Doubly_List<double>LRU_Cache_2; //LRU Cache for double data type
LRU_Cache_2.Set_Capacity(4);
for(i=0;i<7;i++)
{
cout<<"Enter double data: \n";
double d;
cin>>d;
LRU_Cache_2.Insert(d);
}
cout<<"LRU_Cache data: \n";
LRU_Cache_2.Print();
cout<<"\n";
cout<<"Number of Page Faults : "<<LRU_Cache_2.Page_Faults<<"\n";
//Similarly,this can also be used for user defined data types.
return 0;
}