Interface ArrayIterator
- All Superinterfaces:
AutoCloseable
,Iterator<Array>
- All Known Implementing Classes:
JNIArrayIterator
This interface extends both Iterator
and AutoCloseable
, allowing
for efficient iteration over array elements while ensuring proper cleanup of any
underlying resources. The iterator provides access to the data type of the arrays
being iterated over, which is useful for type-safe processing.
Example usage:
try (ArrayIterator iterator = array.getIterator()) {
DType dataType = iterator.getDataType();
while (iterator.hasNext()) {
Array element = iterator.next();
// Process element based on dataType
}
}
- See Also:
-
Method Details
-
getDataType
DType getDataType()Returns the data type of the arrays that this iterator produces.This method provides type information about the arrays that will be returned by subsequent calls to
Iterator.next()
. The data type remains constant throughout the lifetime of the iterator and can be used for type-safe processing and validation.- Returns:
- the
DType
representing the data type of arrays produced by this iterator
-
close
void close()Closes this iterator and releases any underlying resources.This method should be called when the iterator is no longer needed to ensure proper cleanup of any native resources or memory allocations. After calling this method, the iterator should not be used for further operations.
It is recommended to use this iterator within a try-with-resources statement to ensure automatic cleanup:
try (ArrayIterator iterator = array.getIterator()) { // Use iterator } // close() is called automatically
This method overrides
AutoCloseable.close()
and does not throw any checked exceptions, making it safe to use in any context.- Specified by:
close
in interfaceAutoCloseable
- See Also:
-