Interface CloseableIterator<TYPE>
- All Superinterfaces:
AutoCloseable,Iterator<TYPE>
- All Known Subinterfaces:
ByteColumnIterator,CharacterColumnIterator,CloseablePrimitiveIterator<TYPE,,TYPE_CONSUMER> CloseablePrimitiveIteratorOfByte,CloseablePrimitiveIteratorOfChar,CloseablePrimitiveIteratorOfDouble,CloseablePrimitiveIteratorOfFloat,CloseablePrimitiveIteratorOfInt,CloseablePrimitiveIteratorOfLong,CloseablePrimitiveIteratorOfShort,ColumnIterator<DATA_TYPE>,DoubleColumnIterator,FloatColumnIterator,IntegerColumnIterator,LongColumnIterator,ObjectColumnIterator<DATA_TYPE>,ShortColumnIterator,ValueIterator<TYPE>,ValueIteratorOfByte,ValueIteratorOfChar,ValueIteratorOfDouble,ValueIteratorOfFloat,ValueIteratorOfInt,ValueIteratorOfLong,ValueIteratorOfShort
- All Known Implementing Classes:
ChunkedByteColumnIterator,ChunkedCharacterColumnIterator,ChunkedColumnIterator,ChunkedDoubleColumnIterator,ChunkedFloatColumnIterator,ChunkedIntegerColumnIterator,ChunkedLongColumnIterator,ChunkedObjectColumnIterator,ChunkedShortColumnIterator,SerialByteColumnIterator,SerialCharacterColumnIterator,SerialColumnIterator,SerialDoubleColumnIterator,SerialFloatColumnIterator,SerialIntegerColumnIterator,SerialLongColumnIterator,SerialObjectColumnIterator,SerialShortColumnIterator
This interface extends
Iterator and AutoCloseable in order to allow for iterators that acquire
resources that must be released. Such iterators must document this need, and appropriate measures (e.g. a
try-with-resources block) should be taken to ensure that they are closed. Methods that return
streams over CloseableIterator instances should ensure that closing the resulting Stream,
IntStream, LongStream, or
DoubleStream will also close the iterator.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CloseableIterator<?>A re-usable, immutable CloseableIterator with no elements. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()static <TYPE> CloseableIterator<TYPE>concat(@NotNull CloseableIterator<TYPE>... subIterators) Create a CloseableIterator that concatenates an array of non-nullsubIterators.static <TYPE> CloseableIterator<TYPE>empty()Get a CloseableIterator with no elements.static <TYPE> CloseableIterator<TYPE>maybeConcat(@Nullable CloseableIterator<TYPE> first, @Nullable CloseableIterator<TYPE> second, @Nullable CloseableIterator<TYPE> third) Return a CloseableIterator that concatenates the contents of any non-nullCloseableIterator found amongstfirst,second, andthird.static <TYPE> CloseableIterator<TYPE>of(@NotNull TYPE... values) Create a CloseableIterator over an array ofint.static <TYPE> CloseableIterator<TYPE>repeat(TYPE value, long repeatCount) Create a CloseableIterator that repeatsvalue,repeatCounttimes.stream()Create aStreamover the remaining elements of this CloseableIterator.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Field Details
-
EMPTY
A re-usable, immutable CloseableIterator with no elements.
-
-
Method Details
-
stream
Create aStreamover the remaining elements of this CloseableIterator. Closing the result will close this CloseableIterator.- Returns:
- A
Streamover the remaining contents of this iterator
-
close
default void close()- Specified by:
closein interfaceAutoCloseable
-
empty
Get a CloseableIterator with no elements. The result does not need to beclosed.- Returns:
- A CloseableIterator with no elements
-
of
Create a CloseableIterator over an array ofint. The result does not need to beclosed.- Parameters:
values- The elements to iterate- Returns:
- A CloseableIterator of
values
-
repeat
Create a CloseableIterator that repeatsvalue,repeatCounttimes. The result does not need to beclosed.- Parameters:
value- The value to repeatrepeatCount- The number of repetitions- Returns:
- A CloseableIterator that repeats
value,repeatCounttimes
-
concat
@SafeVarargs static <TYPE> CloseableIterator<TYPE> concat(@NotNull @NotNull CloseableIterator<TYPE>... subIterators) Create a CloseableIterator that concatenates an array of non-nullsubIterators. The result only needs to beclosedif any of thesubIteratorsrequire it.- Parameters:
subIterators- The iterators to concatenate, none of which should benull. If directly passing an array, ensure that this iterator has full ownership.- Returns:
- A CloseableIterator concatenating all elements from
subIterators
-
maybeConcat
static <TYPE> CloseableIterator<TYPE> maybeConcat(@Nullable @Nullable CloseableIterator<TYPE> first, @Nullable @Nullable CloseableIterator<TYPE> second, @Nullable @Nullable CloseableIterator<TYPE> third) Return a CloseableIterator that concatenates the contents of any non-nullCloseableIterator found amongstfirst,second, andthird.- Parameters:
first- The first iterator to consider concatenatingsecond- The second iterator to consider concatenatingthird- The third iterator to consider concatenating- Returns:
- A CloseableIterator that concatenates all elements as specified
-