-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmptyList.java
More file actions
35 lines (29 loc) · 791 Bytes
/
EmptyList.java
File metadata and controls
35 lines (29 loc) · 791 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
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
public class EmptyList<T> implements Listuse<T> {
@Override
public int getListSize() {
return 0;
}
@Override
public Listuse<T> filter(Predicate<T> predicate) {
return new EmptyList<>();
}
@Override
public <R> Listuse<R> map(Function<T, R> changeFunction) {
return new EmptyList<>();
}
@Override
public Listuse<T> addFront(T element) {
return new NotEmptyList<>(element, this);
}
@Override
public <R> R fold(R initial, BiFunction<R, T, R> accumulate) {
return initial;
}
@Override
public void forEach(Consumer<T> action) {
}
}