Class IntRangesBuffer

All Implemented Interfaces:
CharacterSet, RangesBuffer, SortedListOfRanges, Iterable<Integer>

public class IntRangesBuffer extends IntArrayBuffer implements RangesBuffer
Extension of IntArrayBuffer that adds convenience functions for arrays of integer ranges in the form:
 [
     inclusive lower bound of range 1, inclusive upper bound of range 1,
     inclusive lower bound of range 2, inclusive upper bound of range 2,
     inclusive lower bound of range 3, inclusive upper bound of range 3,
     ...
 ]
 
  • Constructor Details

    • IntRangesBuffer

      public IntRangesBuffer()
    • IntRangesBuffer

      public IntRangesBuffer(int initialSize)
  • Method Details

    • getLo

      public int getLo(int i)
      Description copied from interface: SortedListOfRanges
      Returns the inclusive lower bound of the range stored at index i.
      Specified by:
      getLo in interface SortedListOfRanges
    • getHi

      public int getHi(int i)
      Description copied from interface: SortedListOfRanges
      Returns the inclusive upper bound of the range stored at index i.
      Specified by:
      getHi in interface SortedListOfRanges
    • size

      public int size()
      Description copied from interface: SortedListOfRanges
      Returns the number of disjoint ranges contained in this list.
      Specified by:
      size in interface SortedListOfRanges
    • appendRange

      public void appendRange(int lo, int hi)
      Description copied from interface: RangesBuffer
      Appends [lo hi] to this list. The given range must be right of and non-adjacent to the last range in this list.
      Specified by:
      appendRange in interface RangesBuffer
    • addSingleValue

      public void addSingleValue(int newValue)
      Adds a new value. The value can be adjacent to the last range, in which case the last range is extended.
    • appendRangeAllowAdjacent

      public void appendRangeAllowAdjacent(int lo, int hi)
    • appendRangeConcatAdjacent

      public void appendRangeConcatAdjacent(int lo, int hi)
    • insertRange

      public void insertRange(int index, int lo, int hi)
      Description copied from interface: RangesBuffer
      Insert [lo hi] at the given index. The given range must be right of and non-adjacent to the range at index - 1, and left of and non-adjacent to the range at index.
      Specified by:
      insertRange in interface RangesBuffer
    • replaceRanges

      public void replaceRanges(int fromIndex, int toIndex, int lo, int hi)
      Description copied from interface: RangesBuffer
      Replace all ranges from fromIndex (inclusive) to toIndex (exclusive) with the single range [lo hi]. The given range must be right of and non-adjacent to the range at fromIndex - 1, and left of and non-adjacent to the range at toIndex.
      Specified by:
      replaceRanges in interface RangesBuffer
    • appendRangesTo

      public void appendRangesTo(RangesBuffer buffer, int startIndex, int endIndex)
      Description copied from interface: SortedListOfRanges
      Append all ranges from startIndex (inclusive) to endIndex (exclusive) to the given buffer. The caller is responsible for not violating the target buffer's sortedness; This effectively means that the range at startIndex must be rightOf the buffer's last range.
      Specified by:
      appendRangesTo in interface SortedListOfRanges
    • create

      public IntRangesBuffer create()
      Description copied from interface: RangesBuffer
      Create a new instance of this class.
      Specified by:
      create in interface RangesBuffer
    • rangesIterator

      public Iterator<Range> rangesIterator()
    • toString

      public String toString()
      Overrides:
      toString in class Object