Skip to content

Commit

Permalink
Update AbstractImmutableSeq
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Dec 31, 2024
1 parent e30036f commit b5f5c54
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,37 +458,37 @@ static <E, T, Builder> T reversed(
}

static <E, U, T, Builder> T mapIndexed(
@NotNull ImmutableSeq<? extends E> Seq,
@NotNull ImmutableSeq<? extends E> seq,
@NotNull IndexedFunction<? super E, ? extends U> mapper,
@NotNull CollectionFactory<? super U, Builder, ? extends T> factory
) {
Objects.requireNonNull(mapper);

Builder builder = factory.newBuilder();

factory.sizeHint(builder, Seq);
factory.sizeHint(builder, seq);

int idx = 0;
for (E e : Seq) {
for (E e : seq) {
factory.addToBuilder(builder, mapper.apply(idx++, e));
}
return factory.build(builder);
}


static <E, U, T, Builder> T mapIndexedNotNull(
@NotNull ImmutableSeq<? extends E> Seq,
@NotNull ImmutableSeq<? extends E> seq,
@NotNull IndexedFunction<? super E, ? extends U> mapper,
@NotNull CollectionFactory<? super U, Builder, ? extends T> factory
) {
Objects.requireNonNull(mapper);

Builder builder = factory.newBuilder();

factory.sizeHint(builder, Seq);
factory.sizeHint(builder, seq);

int idx = 0;
for (E e : Seq) {
for (E e : seq) {
U u = mapper.apply(idx++, e);
if (u != null) {
factory.addToBuilder(builder, u
Expand All @@ -499,7 +499,7 @@ static <E, U, T, Builder> T mapIndexedNotNull(
}

static <E, U, T, Builder> T mapIndexedMulti(
@NotNull ImmutableSeq<? extends E> Seq,
@NotNull ImmutableSeq<? extends E> seq,
@NotNull IndexedBiConsumer<? super E, ? super Consumer<? super U>> mapper,
@NotNull CollectionFactory<? super U, Builder, ? extends T> factory
) {
Expand All @@ -509,7 +509,7 @@ static <E, U, T, Builder> T mapIndexedMulti(
Consumer<U> consumer = u -> factory.addToBuilder(builder, u);

int idx = 0;
for (E e : Seq) {
for (E e : seq) {
mapper.accept(idx++, e, consumer);
}
return factory.build(builder);
Expand Down

0 comments on commit b5f5c54

Please sign in to comment.