Class LazySynchronizedIterator<E>
java.lang.Object
org.apache.sis.internal.util.AbstractIterator<E>
org.apache.sis.referencing.factory.LazySynchronizedIterator<E>
- Type Parameters:
E- the type of elements to be returned by the iterator.
- All Implemented Interfaces:
Iterator<E>
An iterator over all elements given by an array of
Iterable<E>, skipping null elements.
All uses of an Iterable<E> (including its iterator) is synchronized on that Iterable instance.
Note that despite the above-cited synchronization, this iterator is not thread-safe:
each thread needs to use its own iterator instance. However, provided that the above condition is met,
different threads can safely use their iterators concurrently even if the underlying Iterables
were not thread-safe, because of the synchronization on Iterable<E> instances.
- Since:
- 0.7
- Version:
- 0.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe iterator on which to delegate calls tohasNext()andAbstractIterator.next().private intIndex of theIterable<E>instance that provides theitvalue.The providers of iterators.Fields inherited from class AbstractIterator
next -
Constructor Summary
ConstructorsConstructorDescriptionLazySynchronizedIterator(Iterable<? extends E>[] providers) Creates a new iterator over all elements returned by the given providers. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()ReturnstrueifAbstractIterator.next()can return a non-null element.Methods inherited from class AbstractIterator
nextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining, remove
-
Field Details
-
providers
-
providerIndex
private int providerIndexIndex of theIterable<E>instance that provides theitvalue. This is also the instance to use as a synchronization lock. -
it
The iterator on which to delegate calls tohasNext()andAbstractIterator.next(). This iterator is provided byproviders[providerIndex].iterator().
-
-
Constructor Details
-
LazySynchronizedIterator
-
-
Method Details
-
hasNext
public boolean hasNext()ReturnstrueifAbstractIterator.next()can return a non-null element. This method delegates to the iterators of all providers until one is found that return a non-null element.- Returns:
trueif there is more elements to return.
-