Class LocIterator

  • All Implemented Interfaces:
    java.util.Iterator<Location>

    public class LocIterator
    extends java.lang.Object
    implements java.util.Iterator<Location>
    Move a sliding window over a Location. Window size and increment can be specified. If the increment is negative, the iteration starts at end of Location and moves toward beginning.
    Author:
    Hanno Hinsch
    • Constructor Summary

      Constructors 
      Constructor Description
      LocIterator​(Location bounds, int windowSize, int increment)
      Construct an iterator that slides a window over a Location.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Check if next window of default size is available.
      boolean hasNext​(int windowSize, int increment)
      Check if next window of specified size is available.
      static void main​(java.lang.String[] args)
      Deprecated. 
      Location next()
      Get next window of default size, then increment position by default amount.
      Location next​(int windowSize, int increment)
      Get next window of specified size, then increment position by specified amount.
      Location remainder()
      Get portion of bounding location that has not yet been retrieved by next() method.
      void remove()
      Unsupported.
      java.lang.String toString()
      Get string representation of iterator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • LocIterator

        public LocIterator​(Location bounds,
                           int windowSize,
                           int increment)
        Construct an iterator that slides a window over a Location.
        Parameters:
        bounds - The location over which to iterate.
        windowSize - The size of the moving window.
        increment - The increment by which to move the window at each iteration. If increment is positive, the iteration starts at the beginning of the bounding location and moves toward the end; if the increment is negative, the iteration starts at the end and moves toward the begnning.
    • Method Detail

      • hasNext

        public boolean hasNext​(int windowSize,
                               int increment)
        Check if next window of specified size is available.
        Parameters:
        windowSize - Size of window. May be smaller or larger than default window size.
        increment - The increment by which to move the window at each iteration. Note that this method does not actually change the position. However, it checks the sign of the increment parameter to determine the direction of the iteration.
        Returns:
        True if window of specified size is available.
        Throws:
        java.lang.IllegalArgumentException - Window size parameter was not positive.
      • hasNext

        public boolean hasNext()
        Check if next window of default size is available.
        Specified by:
        hasNext in interface java.util.Iterator<Location>
        Returns:
        True if window of default size is available. The default size is the size specified in the LocIterator constructor.
      • remainder

        public Location remainder()
        Get portion of bounding location that has not yet been retrieved by next() method.
        Returns:
        The location not yet retrieved.
      • next

        public Location next()
        Get next window of default size, then increment position by default amount. Both defaults are specified in the LocIterator constructor.
        Specified by:
        next in interface java.util.Iterator<Location>
        Returns:
        Location of next window.
        Throws:
        java.lang.IndexOutOfBoundsException - The next window was not within the bounding location.
      • next

        public Location next​(int windowSize,
                             int increment)
        Get next window of specified size, then increment position by specified amount.
        Parameters:
        windowSize - Size of window to get.
        increment - Amount by which to shift position. If increment is positive, the position is shifted toward the end of the bounding location; if increment is negative, the position is shifted toward the beginning of the bounding location.
        Returns:
        Location of next window.
        Throws:
        java.lang.IndexOutOfBoundsException - The next window was not within the bounding location.
        java.lang.IllegalArgumentException - The increment was zero, or windowSize was not positive.
      • toString

        public java.lang.String toString()
        Get string representation of iterator.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Description of internal state.
      • remove

        public void remove()
        Unsupported.
        Specified by:
        remove in interface java.util.Iterator<Location>
        Throws:
        java.lang.UnsupportedOperationException
      • main

        @Deprecated
        public static void main​(java.lang.String[] args)
        Deprecated.