Lab 08 - Exercise 7, Asynchronous Programming
Exercise 7 Review
head() — Retrieve the Head Safely
tail() — Retrieve the Tail
map() — How to map the List Efficiently
forEach()
public void forEach(Consumer<? super T> action) {
InfiniteList<T> currList = this;
while (!currList.isSentinel()) {
// Consume the head
currList.head.get().ifPresent(action); // Maybe<T>::ifPresent
// Shrink the sublist
currList = currList.tail.get();
}
}public void forEach(Consumer<? super T> action) {
this.head.get().ifPresent(action);
this.tail.get().forEach(action);
}reduce()
Asynchronous Programming
CompletableFuture<T>
CompletableFuture<T>Common Completable Future methods
Last updated