Package ghidra.util

Class MultiComparableArrayIterator<T extends Comparable<T>>

java.lang.Object
ghidra.util.MultiComparableArrayIterator<T>

public class MultiComparableArrayIterator<T extends Comparable<T>> extends Object
MultiComparableArrayIterator takes multiple arrays of comparable objects and iterates through them simultaneously. The arrays must contain objects that are comparable within each array and between the multiple arrays. All arrays must be sorted in ascending order when handed to this class. Iterating returns the next object(s) from one or more of the arrays based on the compareTo() of the next objects in each of the arrays. If a particular array doesn't contain the next object, based on all arrays, then a null is returned as the next object for that array.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor of a multi-comparable object array iterator for traversing multiple comparable object arrays simultaneously.
    MultiComparableArrayIterator(T[][] arrays, boolean forward)
    Constructor of a multi comparable object array iterator for traversing multiple comparable object arrays simultaneously.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether or not any of the original arrays has a next object.
    T[]
    Returns the next comparable object(s).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiComparableArrayIterator

      public MultiComparableArrayIterator(T[][] arrays)
      Constructor of a multi-comparable object array iterator for traversing multiple comparable object arrays simultaneously.
      Important: The items in each array must be in ascending order.
      Parameters:
      arrays - the array of Comparable object arrays. Each array needs to be in ascending order.
    • MultiComparableArrayIterator

      public MultiComparableArrayIterator(T[][] arrays, boolean forward)
      Constructor of a multi comparable object array iterator for traversing multiple comparable object arrays simultaneously.
      Parameters:
      arrays - the array of Comparable object arrays. Each array needs to be in ascending order.
      forward - true indicates that the iterator return comparable objects from min to max. false indicates to iterate backwards (from max to min).
  • Method Details

    • hasNext

      public boolean hasNext()
      Determines whether or not any of the original arrays has a next object.
      Returns:
      true if a next object can be obtained from any of the comparable object arrays.
    • next

      public T[] next()
      Returns the next comparable object(s). The next object could be from any one or more of the arrays. The object array returned corresponds to the comparable arrays originally passed to the constructor. All objects returned are effectively the same as determined by the compareTo() method. If the next object for one of the original comparable arrays is not the same as the next overall object, then a null is returned in its place.
      Returns:
      an array with the next object found for each of the original arrays. Some of these may be null, indicating the corresponding comparable array didn't possess the next object. However, that comparable array may still have objects on subsequent calls. There will be as many elements in this array as the number of comparable arrays passed to the constructor.