-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVideo.java
More file actions
39 lines (32 loc) · 867 Bytes
/
Copy pathVideo.java
File metadata and controls
39 lines (32 loc) · 867 Bytes
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
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.ArrayList;
public class Video implements Comparable<Video> {
int id;
int size;
int totalRequest= 0;
ArrayList<Request> listOfRequest= new ArrayList<Request>();
ArrayList<Integer> cache; // destination
Video(int id, int s){
this.id= id; size = s;
cache = new ArrayList<Integer>();
}
public void addRequest(Request r) {
totalRequest+= r.noOf;
listOfRequest.add(r);
}
public void addCacheServer(int id){
cache.add(id);
}
public void removeCacheServer(int id){
cache.remove(cache.indexOf(id));
}
public void resetCacheServer(){
cache = new ArrayList<Integer>();
}
@Override
public int compareTo(Video o) {
return o.totalRequest - totalRequest; // TODO check
}
}