Package nom.tam.util.array
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 afloat[][][]
array the base would befloat[]
.
Multi-dimensional array iterator (primarily for internal use)
-
Constructor Summary
ConstructorDescriptionMultiArrayIterator
(BaseArray baseArray) Creates a new iterator for a multidimensional array. -
Method Summary
-
Constructor Details
-
MultiArrayIterator
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
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
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 tonext()
would always returnnull
afterwards. As of version 1.20, it consistently returns the same based element count regardless of the state of the iterator (effectively the same asArrayFuncs.countElements(Object)
). Note that this call is expensive, especially for large multidimensional arrays.- Returns:
- the number of base elements contained.
- See Also:
-