Package ca.phon.util

Class Range

java.lang.Object
ca.phon.util.Range
All Implemented Interfaces:
Serializable, Iterable<Integer>

public class Range extends Object implements Iterable<Integer>, Serializable
An iterable integer range.
See Also:
  • Constructor Details

    • Range

      public Range()
    • Range

      public Range(int start, int end)
    • Range

      public Range(int start, int end, boolean excludesEnd)
  • Method Details

    • getStart

      public int getStart()
    • setStart

      public void setStart(int start)
    • getEnd

      public int getEnd()
    • getRange

      public int getRange()
    • setEnd

      public void setEnd(int end)
    • isExcludesEnd

      public boolean isExcludesEnd()
    • getFirst

      public int getFirst()
    • getLast

      public int getLast()
    • setExcludesEnd

      public void setExcludesEnd(boolean excludesEnd)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • iterator

      public Iterator<Integer> iterator()
      Specified by:
      iterator in interface Iterable<Integer>
    • overlaps

      public boolean overlaps(Range anotherRange)
    • contains

      public boolean contains(Range anotherRange)
    • contains

      public boolean contains(int val)
    • intersect

      public Range intersect(Range anotherRange)
    • main

      public static void main(String[] args)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromString

      public static Range fromString(String rangeStr)
      Parse a string into a range object. Supported formats are the same as return values from toString()
      Parameters:
      rangeStr -
      Returns:
      Range
    • reduceRanges

      public static List<Range> reduceRanges(List<Range> ranges)
      This method takes a list of ranges and attempts to reduce them. If one range is completely contained within another only the larger range is kept.
      Parameters:
      ranges -
      Returns:
      List