Class MultiArrayIterator<BaseArray>

java.lang.Object
nom.tam.util.array.MultiArrayIterator<BaseArray>
Type Parameters:
BaseArray - the generic type of array at the base of a multi-dimensional array object. For example for a float[][][] array the base would be float[].

public class MultiArrayIterator<BaseArray> extends Object
Multi-dimensional array iterator (primarily for internal use)
  • Constructor Details

    • MultiArrayIterator

      public MultiArrayIterator(BaseArray baseArray)
      Creates a new iterator for a multidimensional array. The array is assumed to be monolithic containing only one type of (non-array) elements.
      Parameters:
      baseArray - the multidimensional array, whose elements we want to iterate over.
  • Method Details

    • deepComponentType

      public Class<?> deepComponentType()

      Returns the element class of the multidimensional array. It is assumed that the array is monolithic containing only elements of that type. This is effectively the same as ArrayFuncs.getBaseClass(Object).

      Note that prior to version 1.20, this did not return the expected type for 3D+ arrays.

      Returns:
      the class of (non-array) elements contained in the multidimensional array.
      See Also:
    • next

      public BaseArray next()
      Returns the next array element in the top-level array.
      Returns:
      the next array element in the top-level array object.
    • reset

      public void reset()
      Resets the iterator so it can be re-used again.
    • size

      public int size()
      Counts the number of base elements contained. Prior to version 1.20 this returned the number of elements remaining from the current position, but by iterating over the remaining elements, s.t. a call to next() would always return null afterwards. As of version 1.20, it consistently returns the same based element count regardless of the state of the iterator (effectively the same as ArrayFuncs.countElements(Object)). Note that this call is expensive, especially for large multidimensional arrays.
      Returns:
      the number of base elements contained.
      See Also: