-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPage.java
55 lines (49 loc) · 1.02 KB
/
Page.java
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* This class represents a page of memory.
*
*
*/
public class Page implements Comparable<Page>{
int lastUsed;
int pageNum;
public static int useCount=0;
public Page(int pageNum){
this.pageNum=pageNum;
this.lastUsed=useCount++;
}
/**
*access method call increments the lastUsed count
*/
public void access(){
this.lastUsed=useCount++;
}
/**
* compare the lru last used page count.
* TODO: get around to changing this to a boolean method
*
*/
@Override
public int compareTo(Page other) {
if (this.lastUsed < other.lastUsed) {
return -1;
} else if (this.lastUsed > other.lastUsed) {
return 1;
}
return 0;
}
/**
* When you call the equals method, it returns
* a boolean that tells you if an index is equal
* to the current Page's index.
*/
public boolean equals(int i){
return pageNum==i;
}
/**
* returns a string of Page information. It shows the pageNum and page count.
*/
public String toString() {
String s = pageNum + " " + useCount;
return s;
}
}