-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPendingRequests.java
57 lines (52 loc) · 1.23 KB
/
PendingRequests.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
56
57
import Includes.*;
public class PendingRequests {
private int length = 0;
private Node<RequestData> front;
private Node<RequestData> back;
public boolean insert(Node<RequestData> insnode) {
/*
* Your code here.
*/
if (front == null){
front = insnode;
back=front;
}
else{
insnode.previous=back;
back.next=insnode;
back = insnode;
}
length ++;
return true;
}
public boolean delete(Node<RequestData> delnode) {
/*
* Your code here.
*/
delnode.previous.next=delnode.next;
delnode.next.previous=delnode.previous;
length --;
return true;
}
public Node<RequestData> find(int ISBN) {
/*
* Your code here.
*/
Node<RequestData> currentNode=front;
for (; currentNode!=null; currentNode=currentNode.next){
if (currentNode.data.ISBN == ISBN){
break ;
}
}
return currentNode;
}
public String toString(){
Node<RequestData> temp = front;
String s = "Length: " + length + "\n";
while(temp != null){
s+=temp.data.toString();
temp = temp.next;
}
return s;
}
}