Interface SortedListOfRanges
- All Superinterfaces:
CharacterSet
- All Known Subinterfaces:
ImmutableSortedListOfRanges,RangesBuffer
- All Known Implementing Classes:
CaseFoldData.CaseFoldEquivalenceTable,CaseFoldData.CaseFoldTable,CodePointSet,ImmutableSortedListOfIntRanges,IntRangesBuffer
A storage-agnostic implementation of a sorted list of disjoint integer ranges with inclusive
lower and upper bounds. Holds the invariant
rangesAreSortedNonAdjacentAndDisjoint().-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddRangeTo(RangesBuffer buffer, int i) Appends the range at indexito the givenbuffer.default booleanadjacent(int ia, int bLo, int bHi) Returnstrueif the range at indexiais adjacent to the range[bLo, bHi].static booleanadjacent(int aLo, int aHi, int bLo, int bHi) Returnstrueif the ranges[aLo, aHi]and[bLo, bHi]are adjacent to each other, meaning that the lower bound of one range immediately follows the upper bound of the other.default booleanadjacent(int ia, SortedListOfRanges o, int ib) Returnstrueif the range at indexiais adjacent to the range in listoat indexib.voidappendRangesTo(RangesBuffer buffer, int startIndex, int endIndex) Append all ranges fromstartIndex(inclusive) toendIndex(exclusive) to the givenbuffer.default intbinarySearch(int keyLo) Performs a binary search for a range with the given lower bound (keyLo), in the same way asArrays.binarySearch(int[], int)would behave on an array containing only the lower bounds of all ranges in this list.default booleanbinarySearchExactMatch(int searchResult, int bLo, int bHi) Returnstrueif a given binary search result is equals to the range[bLo, bHi].default booleanbinarySearchExactMatch(int searchResult, SortedListOfRanges o, int ib) Returnstrueif a given binary search result is equal to the range in listoat indexib.default intbinarySearchGetFirstIntersecting(int searchResult, int bLo, int bHi) If there was noexact matchin abinary search, this method will return the index of the first range that intersects with the range[bLo, bHi], orsize().default intbinarySearchGetFirstIntersecting(int searchResult, SortedListOfRanges o, int ib) If there was noexact matchin abinary search, this method will return the index of the first range that intersects with the range inoat indexib, orsize().default intbinarySearchGetFirstIntersectingOrAdjacent(int searchResult, int bLo, int bHi) If there was noexact matchin abinary search, this method will return the index of the first range that intersects with or is adjacent to the range[bLo, bHi], orsize().default intbinarySearchGetFirstIntersectingOrAdjacent(int searchResult, int oLo, int oHi, boolean includeAdjacent) default booleanbinarySearchNoIntersectingFound(int firstIntersecting) Returnstrueif no intersecting range was found by a call tobinarySearchGetFirstIntersecting(int, int, int)or one if its variants.default booleancontainedBy(int ia, int bLo, int bHi) Returnstrueif the range[bLo, bHi]contains the range at indexia.default booleancontains(int codePoint) Returnstrueif this list contains the givencodePoint.default booleancontains(int ia, int bLo, int bHi) Returnstrueif the range at indexiacontains the range[bLo, bHi].static booleancontains(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]contains the range[bLo, bHi].default booleancontains(int ia, SortedListOfRanges o, int ib) Returnstrueif the range at indexiacontains the range in listoat indexib.default booleanReturnstrueif this list contains all values ofo.default Stringdefault booleanequal(int ia, int bLo, int bHi) Returnstrueif the range at indexiais equal to the range[bLo, bHi].default booleanequal(int ia, SortedListOfRanges o, int ib) Returnstrueif the range at indexiais equal to the range in listoat indexib.default booleanintgetHi(int i) Returns the inclusive upper bound of the range stored at indexi.intgetLo(int i) Returns the inclusive lower bound of the range stored at indexi.default intgetMax()Returns the largest value contained in this set.default intgetMin()Returns the smallest value contained in this set.static voidintersect(SortedListOfRanges a, SortedListOfRanges b, RangesBuffer target) Convertstargetto the intersection ofaandb.default booleanintersects(int ia, int bLo, int bHi) Returnstrueif the range at indexiaintersects with the range[bLo, bHi].static booleanintersects(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]intersects with the range[bLo, bHi].default booleanintersects(int ia, SortedListOfRanges o, int ib) Returnstrueif the range at indexiaintersects with the range in listoat indexib.default booleanReturnstrueif this list intersects witho.default intinverseGetMax(Encodings.Encoding encoding) Returns the largest value contained in the inverse of this set.default intinverseGetMin(Encodings.Encoding encoding) Returns the smallest value contained in the inverse of this set.default StringinverseRangesToString(Encodings.Encoding encoding) default intinverseValueCount(Encodings.Encoding encoding) Returns the total number of values (fromEncodings.Encoding.getMinValue()toEncodings.Encoding.getMaxValue()) not contained in this list.static voidinvert(SortedListOfRanges a, Encodings.Encoding encoding, RangesBuffer target) default booleanisEmpty()default booleanisSingle(int i) Returnstrueif the range at indexiconsists of a single value, i.e.static booleanleftOf(int aHi, int bLo) Variant ofleftOf(int, int, int, int)without the unnecessary parameters.default booleanleftOf(int ia, int bLo, int bHi) Returnstrueif the range at indexiais "left of" the range[bLo, bHi].static booleanleftOf(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]is "left of" the range[bLo, bHi], where "left of" means "all values of range a are less than all values of range b" - i.e.default booleanleftOf(int ia, SortedListOfRanges o, int ib) Returnstrueif the range at indexiais "left of" the range in listoat indexib.default booleanReturnstrueiff this code point set contains exactly two characters whose binary representation differs in one bit only.default booleanmatchesEverything(Encodings.Encoding encoding) Returnstrueif this list is equal to [Encodings.Encoding.getMinValue()Encodings.Encoding.getMaxValue()].default booleanmatchesMinAndMax(Encodings.Encoding encoding) Returnstrueiff this set containsEncodings.Encoding.getMinValue()andEncodings.Encoding.getMaxValue().default booleanReturnstrueif this list is empty.default booleanReturnstrueif this list contains just one single value which is less than 128.default booleanReturnstrueif this list contains just one single value.default booleanReturnstrueif this list is non-empty.default booleanReturnstrueif this list is sorted and all of its ranges are disjoint.default booleanReturnstrueif this list is sorted and all of its ranges are disjoint and non-adjacent.default Stringstatic booleanrightOf(int aLo, int bHi) Variant ofrightOf(int, int, int, int)without the unnecessary parameters.default booleanrightOf(int ia, int bLo, int bHi) Returnstrueif the range at indexiais "right of" the range[bLo, bHi].static booleanrightOf(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]is "right of" the range[bLo, bHi], where "right of" means "all values of range a are greater than all values of range b" - i.e.default booleanrightOf(int ia, SortedListOfRanges o, int ib) Returnstrueif the range at indexiais "right of" the range in listoat indexib.intsize()Returns the number of disjoint ranges contained in this list.default intsize(int i) Returns the number of values contained in the range at indexi.default intsizeOfInverse(Encodings.Encoding encoding) Returns the number of disjoint ranges contained in the inverse (as defined byImmutableSortedListOfRanges.createInverse(Encoding)) of this list.static voidunion(SortedListOfRanges a, SortedListOfRanges b, RangesBuffer target) Convertstargetto the union ofaandb.default intReturns the total number of values contained in this list.default booleanvalueCountEquals(int cmp) Returnstrueiff the total number of values contained in this list is equal tocmp.default booleanvalueCountMax(int cmp) Returnstrueiff the total number of values contained in this list is less or equal tocmp.
-
Method Details
-
getLo
int getLo(int i) Returns the inclusive lower bound of the range stored at indexi. -
getHi
int getHi(int i) Returns the inclusive upper bound of the range stored at indexi. -
size
int size()Returns the number of disjoint ranges contained in this list. -
appendRangesTo
Append all ranges fromstartIndex(inclusive) toendIndex(exclusive) to the givenbuffer. The caller is responsible for not violating the target buffer's sortedness; This effectively means that the range atstartIndexmust berightOfthe buffer's last range. -
isEmpty
default boolean isEmpty() -
isSingle
default boolean isSingle(int i) Returnstrueif the range at indexiconsists of a single value, i.e.getLo(i) == getHi(i). -
size
default int size(int i) Returns the number of values contained in the range at indexi. -
sizeOfInverse
Returns the number of disjoint ranges contained in the inverse (as defined byImmutableSortedListOfRanges.createInverse(Encoding)) of this list. -
getMin
default int getMin()Returns the smallest value contained in this set. Must not be called on empty sets. -
getMax
default int getMax()Returns the largest value contained in this set. Must not be called on empty sets. -
inverseGetMin
Returns the smallest value contained in the inverse of this set. Must not be called on empty or full sets. -
inverseGetMax
Returns the largest value contained in the inverse of this set. Must not be called on empty or full sets. -
contains
static boolean contains(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]contains the range[bLo, bHi]. -
contains
Returnstrueif the range at indexiacontains the range in listoat indexib. -
contains
default boolean contains(int ia, int bLo, int bHi) Returnstrueif the range at indexiacontains the range[bLo, bHi]. -
containedBy
default boolean containedBy(int ia, int bLo, int bHi) Returnstrueif the range[bLo, bHi]contains the range at indexia. -
intersects
static boolean intersects(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]intersects with the range[bLo, bHi]. -
intersects
Returnstrueif the range at indexiaintersects with the range in listoat indexib. -
intersects
default boolean intersects(int ia, int bLo, int bHi) Returnstrueif the range at indexiaintersects with the range[bLo, bHi]. -
leftOf
static boolean leftOf(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]is "left of" the range[bLo, bHi], where "left of" means "all values of range a are less than all values of range b" - i.e. {code aHi < bLo}. -
leftOf
static boolean leftOf(int aHi, int bLo) Variant ofleftOf(int, int, int, int)without the unnecessary parameters. -
leftOf
Returnstrueif the range at indexiais "left of" the range in listoat indexib.- See Also:
-
leftOf
default boolean leftOf(int ia, int bLo, int bHi) Returnstrueif the range at indexiais "left of" the range[bLo, bHi].- See Also:
-
rightOf
static boolean rightOf(int aLo, int aHi, int bLo, int bHi) Returnstrueif the range[aLo, aHi]is "right of" the range[bLo, bHi], where "right of" means "all values of range a are greater than all values of range b" - i.e. {code aLo > bHi}. -
rightOf
static boolean rightOf(int aLo, int bHi) Variant ofrightOf(int, int, int, int)without the unnecessary parameters. -
rightOf
Returnstrueif the range at indexiais "right of" the range in listoat indexib.- See Also:
-
rightOf
default boolean rightOf(int ia, int bLo, int bHi) Returnstrueif the range at indexiais "right of" the range[bLo, bHi].- See Also:
-
adjacent
static boolean adjacent(int aLo, int aHi, int bLo, int bHi) Returnstrueif the ranges[aLo, aHi]and[bLo, bHi]are adjacent to each other, meaning that the lower bound of one range immediately follows the upper bound of the other. -
adjacent
Returnstrueif the range at indexiais adjacent to the range in listoat indexib.- See Also:
-
adjacent
default boolean adjacent(int ia, int bLo, int bHi) Returnstrueif the range at indexiais adjacent to the range[bLo, bHi].- See Also:
-
equal
Returnstrueif the range at indexiais equal to the range in listoat indexib. -
equal
default boolean equal(int ia, int bLo, int bHi) Returnstrueif the range at indexiais equal to the range[bLo, bHi]. -
binarySearch
default int binarySearch(int keyLo) Performs a binary search for a range with the given lower bound (keyLo), in the same way asArrays.binarySearch(int[], int)would behave on an array containing only the lower bounds of all ranges in this list. -
binarySearchExactMatch
Returnstrueif a given binary search result is equal to the range in listoat indexib.- Parameters:
searchResult- the result of a call tobinarySearch(int)witho.getLo(ib)as the parameter.
-
binarySearchExactMatch
default boolean binarySearchExactMatch(int searchResult, int bLo, int bHi) Returnstrueif a given binary search result is equals to the range[bLo, bHi].- Parameters:
searchResult- the result of a call tobinarySearch(int)withbLoas the parameter.
-
binarySearchGetFirstIntersecting
If there was noexact matchin abinary search, this method will return the index of the first range that intersects with the range inoat indexib, orsize().- Parameters:
searchResult- the result of a call tobinarySearch(int)witho.getLo(ib)as the parameter.
-
binarySearchGetFirstIntersecting
default int binarySearchGetFirstIntersecting(int searchResult, int bLo, int bHi) If there was noexact matchin abinary search, this method will return the index of the first range that intersects with the range[bLo, bHi], orsize().- Parameters:
searchResult- the result of a call tobinarySearch(int)withbLoas the parameter.
-
binarySearchGetFirstIntersectingOrAdjacent
default int binarySearchGetFirstIntersectingOrAdjacent(int searchResult, int bLo, int bHi) If there was noexact matchin abinary search, this method will return the index of the first range that intersects with or is adjacent to the range[bLo, bHi], orsize().- Parameters:
searchResult- the result of a call tobinarySearch(int)withbLoas the parameter.
-
binarySearchGetFirstIntersectingOrAdjacent
default int binarySearchGetFirstIntersectingOrAdjacent(int searchResult, int oLo, int oHi, boolean includeAdjacent) -
binarySearchNoIntersectingFound
default boolean binarySearchNoIntersectingFound(int firstIntersecting) Returnstrueif no intersecting range was found by a call tobinarySearchGetFirstIntersecting(int, int, int)or one if its variants.- Parameters:
firstIntersecting- the result of a call tobinarySearchGetFirstIntersecting(int, int, int)or one if its variants.
-
addRangeTo
Appends the range at indexito the givenbuffer. -
rangesAreSortedNonAdjacentAndDisjoint
default boolean rangesAreSortedNonAdjacentAndDisjoint()Returnstrueif this list is sorted and all of its ranges are disjoint and non-adjacent. This property must hold at all times. -
rangesAreSortedAndDisjoint
default boolean rangesAreSortedAndDisjoint()Returnstrueif this list is sorted and all of its ranges are disjoint. This property must hold at all times. -
contains
default boolean contains(int codePoint) Returnstrueif this list contains the givencodePoint.- Specified by:
containsin interfaceCharacterSet
-
contains
Returnstrueif this list contains all values ofo. -
intersects
Returnstrueif this list intersects witho. -
union
Convertstargetto the union ofaandb. -
intersect
Convertstargetto the intersection ofaandb. -
invert
-
matchesNothing
default boolean matchesNothing()Returnstrueif this list is empty. -
matchesSomething
default boolean matchesSomething()Returnstrueif this list is non-empty. -
matchesSingleChar
default boolean matchesSingleChar()Returnstrueif this list contains just one single value. -
matchesSingleAscii
default boolean matchesSingleAscii()Returnstrueif this list contains just one single value which is less than 128. -
matchesMinAndMax
Returnstrueiff this set containsEncodings.Encoding.getMinValue()andEncodings.Encoding.getMaxValue(). -
matches2CharsWith1BitDifference
default boolean matches2CharsWith1BitDifference()Returnstrueiff this code point set contains exactly two characters whose binary representation differs in one bit only. -
valueCount
default int valueCount()Returns the total number of values contained in this list. -
valueCountEquals
default boolean valueCountEquals(int cmp) Returnstrueiff the total number of values contained in this list is equal tocmp. -
valueCountMax
default boolean valueCountMax(int cmp) Returnstrueiff the total number of values contained in this list is less or equal tocmp. -
inverseValueCount
Returns the total number of values (fromEncodings.Encoding.getMinValue()toEncodings.Encoding.getMaxValue()) not contained in this list. -
matchesEverything
Returnstrueif this list is equal to [Encodings.Encoding.getMinValue()Encodings.Encoding.getMaxValue()]. -
equalsListOfRanges
-
defaultToString
-
rangesToString
-
inverseRangesToString
-