-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmptyList.java
More file actions
50 lines (41 loc) · 817 Bytes
/
Copy pathEmptyList.java
File metadata and controls
50 lines (41 loc) · 817 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
40
41
42
43
44
45
46
47
48
49
50
/**
* CS2030S PE1 Question 2
* AY20/21 Semester 2
*
* @author A0218230U
*/
public class EmptyList<T> implements SourceList<T> {
@Override
public T getFirst() {
return null;
}
@Override
public SourceList<T> getSecond() {
return null;
}
@Override
public String toString() {
return "EmptyList";
}
// Write your code here
@Override
public int length() {
return 0;
}
@Override
public boolean equals(Object compared) {
if (compared instanceof EmptyList<?>) {
return true;
} else {
return false;
}
}
@Override
public SourceList<T> filter(BooleanCondition<? super T> cond) {
return new EmptyList();
}
@Override
public <U> SourceList<U> map(Transformer<? super T, ? extends U> trans) {
return new EmptyList();
}
}