Interface ArrayIterator

All Superinterfaces:
AutoCloseable, Iterator<Array>
All Known Implementing Classes:
JNIArrayIterator

public interface ArrayIterator extends AutoCloseable, Iterator<Array>
An iterator interface for traversing Vortex arrays while providing type information and resource management capabilities.

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 Summary

    Modifier and Type
    Method
    Description
    void
    Closes this iterator and releases any underlying resources.
    Returns the data type of the arrays that this iterator produces.

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove
  • 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 interface AutoCloseable
      See Also: