Skip to content

Commit

Permalink
4.x: Remove unused inner class MultiIterable
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 committed Nov 25, 2024
1 parent 7f9d8ac commit affb369
Showing 1 changed file with 1 addition and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,9 +17,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -252,59 +250,4 @@ private Optional<String> scopeFromTags(Iterable<Tag> tags) {
: Optional.empty();
}

static class MultiIterable<T> implements Iterable<T> {

private final Iterable<T>[] iterables;

private MultiIterable(Iterable<T>... iterables) {
if (iterables.length == 0) {
throw new IllegalArgumentException("Must provide at least one Iterable");
}
this.iterables = iterables;
}

@Override
public Iterator<T> iterator() {
return new Iterator<T>() {

private int nextIndex = 0;
private Iterator<T> current = nextIterator();

@Override
public boolean hasNext() {
if (current.hasNext()) {
return true;
}

current = nextIterator();
return current.hasNext();
}

@Override
public T next() {
return current.next();
}

private Iterator<T> nextIterator() {
while (nextIndex < iterables.length) {
Iterator<T> candidateNextIterator = iterables[nextIndex].iterator();
if (candidateNextIterator.hasNext()) {
nextIndex++;
return candidateNextIterator;
}
nextIndex++;
}
return Collections.emptyIterator();
}
};
}

@Override
public void forEach(Consumer<? super T> action) {
for (Iterable<T> it : iterables) {
it.forEach(action);
}
}
}

}

0 comments on commit affb369

Please sign in to comment.