feat: Add dropRepeated stream operator. (#1868)

This commit is contained in:
He-Pin(kerr) 2025-05-29 06:43:17 +08:00 committed by GitHub
parent 9227912ea6
commit e6662e12de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 423 additions and 5 deletions

View file

@ -58,16 +58,12 @@ import java.util.*;
// #zip
// #log
import org.apache.pekko.event.LogMarker;
import org.apache.pekko.stream.Attributes;
// #log
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import java.util.stream.Collectors;
class SourceOrFlow {
private static ActorSystem system = null;
@ -608,6 +604,21 @@ class SourceOrFlow {
// #filterNot
}
void dropRepeatedExample() {
// #dropRepeated
Source.from(Arrays.asList(1, 2, 2, 3, 3, 1, 4))
.dropRepeated()
.runForeach(System.out::println, system);
// prints:
// 1
// 2
// 3
// 1
// 4
// #dropRepeated
}
void dropExample() {
// #drop
Source<Integer, NotUsed> fiveIntegers = Source.from(Arrays.asList(1, 2, 3, 4, 5));