-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestPrep.java
52 lines (41 loc) · 967 Bytes
/
TestPrep.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
public class TestPrep {
public static void shiftRight(Object[] array, int index, Object value) {
for(int i = array.length - 1; i > index; i--) {
array[i + 1] = array[i];
}
array[index] = value;
}
public static int length(Node n) {
Node p = n;
int len = 0;
while (p != null) {
len++;
p = p.next;
}
return len;
}
@Override
public boolean equals(Set<T> s) {
if (s.size() != size) {
return false;
}
for (T element : this) {
if (!s.contains(element)) {
return false;
}
}
return true;
}
public T max() {
Node temp = front.next;
T max = front.element;
while (temp != null) {
T candidate = temp.element;
if (candidate.compareTo(max) > 0) {
max = candidate;
}
temp = temp.next;
}
return max;
}
}