final class CharRanges
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static CharRanges |
ALL_CODE_UNITS |
static CharRanges |
EMPTY |
private int[] |
ranges
A strictly increasing set of bit indices where even members are the
inclusive starts of ranges, and odd members are the exclusive ends.
|
Modifier | Constructor and Description |
---|---|
private |
CharRanges(int[] ranges) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(int bit) |
boolean |
containsAll(CharRanges sub) |
CharRanges |
difference(CharRanges subtrahendRanges) |
int |
end(int i) |
boolean |
equals(java.lang.Object o) |
int |
getNumRanges() |
int |
hashCode() |
static CharRanges |
inclusive(int start,
int end) |
private static int[] |
intArrayToRanges(int[] members) |
CharRanges |
intersection(CharRanges other) |
boolean |
isEmpty() |
CharRanges |
shift(int delta)
Shifts the bits matched by the given delta.
|
int |
start(int i) |
java.lang.String |
toString() |
CharRanges |
union(CharRanges other) |
static CharRanges |
withMembers(int... members)
Returns an instance containing all and only the given members.
|
static CharRanges |
withRanges(int... ranges)
Returns an instance containing the given ranges.
|
private final int[] ranges
E.g., { 1, 5, 6, 10 } represents the set ( 1, 2, 3, 4, 6, 7, 8, 9 ).
public static final CharRanges EMPTY
public static final CharRanges ALL_CODE_UNITS
public static CharRanges inclusive(int start, int end)
public static CharRanges withMembers(int... members)
public static CharRanges withRanges(int... ranges)
ranges
- An even-length ordered sequence of non-overlapping,
non-contiguous, [inclusive start, exclusive end) ranges.private static int[] intArrayToRanges(int[] members)
public boolean contains(int bit)
public boolean isEmpty()
public int getNumRanges()
public int start(int i)
public int end(int i)
public CharRanges union(CharRanges other)
public CharRanges intersection(CharRanges other)
public CharRanges difference(CharRanges subtrahendRanges)
public boolean containsAll(CharRanges sub)
public CharRanges shift(int delta)
java.lang.IndexOutOfBoundsException
- if shifting by delta would cause an
overflow or underflow in a 32 bit signed int
range boundary.
Since the end boundaries of ranges are exclusive, even if there is no
range containing Integer.MAX_VALUE
, shifting by a delta of 1
can cause an overflow.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object