public class Iterators extends Object
Iterator
implementations.AdaptedIterator
Modifier and Type | Class and Description |
---|---|
static interface |
Iterators.CountingPredicate<T> |
static class |
Iterators.DuplicateFilterIterator<T>
Remove duplicates from another iterator.
|
static class |
Iterators.FilterIterator<T>
Creates a filtered view of another iterator.
|
static class |
Iterators.FlattenIterator<U,T>
Produces {A,B,C,D,E,F} from {{A,B},{C},{},{D,E,F}}.
|
Constructor and Description |
---|
Iterators() |
Modifier and Type | Method and Description |
---|---|
static <T> Iterable<T> |
cast(Iterable<? extends T> itr)
Casts
Iterable by taking advantage of its covariant-ness. |
static <T> Iterator<T> |
cast(Iterator<? extends T> itr)
Casts
Iterator by taking advantage of its covariant-ness. |
static <T> Iterator<T> |
empty()
Returns the empty iterator.
|
static <T> Iterator<T> |
limit(Iterator<? extends T> base,
Iterators.CountingPredicate<? super T> filter)
Returns the elements in the base iterator until it hits any element that doesn't satisfy the filter.
|
static <T> Iterator<T> |
readOnly(Iterator<T> itr)
Creates a read-only mutator that disallows
Iterator.remove() . |
static <T> Iterable<T> |
removeDups(Iterable<T> base)
Filters another iterator by eliminating duplicates.
|
static <T> Iterator<T> |
removeDups(Iterator<T> iterator)
Filters another iterator by eliminating duplicates.
|
static <T> Iterator<T> |
removeNull(Iterator<T> itr)
Wraps another iterator and throws away nulls.
|
static <T> Iterable<T> |
reverse(List<T> lst)
Returns the
Iterable that lists items in the reverse order. |
static List<Integer> |
reverseSequence(int start,
int end) |
static List<Integer> |
reverseSequence(int start,
int end,
int step)
The short cut for
reverse(sequence(start,end,step)) . |
static List<Integer> |
sequence(int start,
int end) |
static List<Integer> |
sequence(int start,
int end,
int step)
Returns a list that represents [start,end).
|
static <T> Iterable<T> |
sequence(Iterable<? extends T>... iterables)
|
static <T> Iterator<T> |
sequence(Iterator<? extends T>... iterators) |
static void |
skip(Iterator<?> iterator,
int count)
Similar to
Iterators.skip(java.util.Iterator<T>, int) except not Beta . |
static <U,T extends U> |
subType(Iterator<U> itr,
Class<T> type)
Returns an
Iterator that only returns items of the given subtype. |
static <T> Iterable<T> |
wrap(Iterable<T> base)
Returns an
Iterable that lists items in the normal order
but which hides the base iterator implementation details. |
public static <T> Iterator<T> empty()
public static <T> Iterable<T> reverse(List<T> lst)
Iterable
that lists items in the reverse order.public static <T> Iterable<T> wrap(Iterable<T> base)
Iterable
that lists items in the normal order
but which hides the base iterator implementation details.public static List<Integer> sequence(int start, int end, int step)
public static List<Integer> reverseSequence(int start, int end, int step)
reverse(sequence(start,end,step))
.public static <T> Iterator<T> cast(Iterator<? extends T> itr)
Iterator
by taking advantage of its covariant-ness.public static <T> Iterable<T> cast(Iterable<? extends T> itr)
Iterable
by taking advantage of its covariant-ness.public static <U,T extends U> Iterator<T> subType(Iterator<U> itr, Class<T> type)
Iterator
that only returns items of the given subtype.public static <T> Iterator<T> readOnly(Iterator<T> itr)
Iterator.remove()
.public static <T> Iterator<T> removeNull(Iterator<T> itr)
@SafeVarargs public static <T> Iterable<T> sequence(Iterable<? extends T>... iterables)
public static <T> Iterator<T> removeDups(Iterator<T> iterator)
public static <T> Iterable<T> removeDups(Iterable<T> base)
@SafeVarargs public static <T> Iterator<T> sequence(Iterator<? extends T>... iterators)
public static <T> Iterator<T> limit(Iterator<? extends T> base, Iterators.CountingPredicate<? super T> filter)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void skip(@NonNull Iterator<?> iterator, int count)
Iterators.skip(java.util.Iterator<T>, int)
except not Beta
.iterator
- some iteratorcount
- a nonnegative countCopyright © 2004–2021. All rights reserved.