-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmptyList.java
More file actions
49 lines (41 loc) · 774 Bytes
/
EmptyList.java
File metadata and controls
49 lines (41 loc) · 774 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
/**
* CS2030S PE1 Question 2
* AY20/21 Semester 2
*
* @author A0238768J
*/
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 o) {
if (o instanceof EmptyList<?>) {
return true;
} else {
return false;
}
}
@Override
public SourceList<T> filter(BooleanCondition cond) {
return this;
}
@Override
public <U> SourceList<U> map(Transformer<? super T, ? extends U> trans) {
return new EmptyList<U>();
}
}