Class IntCharSet
java.lang.Object
jflex.core.unicode.IntCharSet
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIterator for enumerating the elements of this IntCharSet -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int c) Adds a single character.voidAdds a single interval to this IntCharSet.voidadd(IntCharSet set) Merges the given set into this one.static IntCharSetallChars()Creates the set of all characters.and(IntCharSet set) Intersects two sets.static IntCharSetReturns the complement of the specified set x, that is, the set of all elements that are not contained in x.booleancontains(int singleChar) Returns whether this set contains a given character.booleancontains(IntCharSet other) Check whether this set contains a another set.booleanReturns whether the set contains elements.static IntCharSetcopyOf(IntCharSet intCharSet) Creates a IntCharSet from an existing IntCharSet.booleangetCaseless(UnicodeProperties unicodeProperties) Create a caseless version of this charset.(package private) IntervalReturns the intervals.inthashCode()private intindexOf(int c) Returns the index of the interval that contains the characterc.(package private) booleanChecks the invariants of this object.(package private) static booleanisSubSet(IntCharSet s1, IntCharSet s2) Very slow but elementary method to determine whether s1 is a subset of s2.iterator()static IntCharSetnlChars()The set of new-line characters.intReturns the number of intervals.static IntCharSetCreates a charset that contains only one interval.static IntCharSetCreates a charset that contains the given intervals.static IntCharSetofCharacter(int singleChar) Creates a char set that contains only the given character.static IntCharSetofCharacterRange(int start, int end) Creates a charset that contains only one interval, given by itsstartandendvalues.intsize()Computes the size of this set.voidsub(IntCharSet set) Returns the relative complement of this set relative to the provided set.toString()Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
DEBUG
private static final boolean DEBUG- See Also:
-
intervals
-
-
Constructor Details
-
IntCharSet
public IntCharSet()
-
-
Method Details
-
of
Creates a charset that contains only one interval. -
of
Creates a charset that contains the given intervals.- Parameters:
intervals- the intervals the new set should contains.- Returns:
- a new IntCharSet with the given intervals.
-
ofCharacterRange
Creates a charset that contains only one interval, given by itsstartandendvalues. -
ofCharacter
Creates a char set that contains only the given character. -
allChars
Creates the set of all characters.- Returns:
- a new IntCharSet that contains all characters.
-
nlChars
The set of new-line characters.- Returns:
- a new IntCharSet that contains all characters that are considered a new-line char in Java.
-
indexOf
private int indexOf(int c) Returns the index of the interval that contains the characterc.Binary search which interval contains the given character.
- Parameters:
c- the character to search for- Returns:
- the index of the enclosing interval, or -1 if no such interval
-
add
Merges the given set into this one. -
add
-
add
public void add(int c) Adds a single character.- Parameters:
c- Character to add.
-
contains
public boolean contains(int singleChar) Returns whether this set contains a given character.- Parameters:
singleChar- a single character (int).- Returns:
- true iff singleChar is contained in the set.
-
contains
Check whether this set contains a another set.- Parameters:
other- an IntCharSet.- Returns:
- true iff all characters of
otherare contained in this set.
-
equals
-
hashCode
-
and
Intersects two sets.- Parameters:
set- aIntCharSetobject.- Returns:
- the
IntCharSetcommon to the two sets.
-
sub
Returns the relative complement of this set relative to the provided set.Assumes that
setis non-null, and contained in this IntCharSet.- Parameters:
set- aIntCharSetto substract from this set.
-
complementOf
Returns the complement of the specified set x, that is, the set of all elements that are not contained in x.- Parameters:
x- theIntCharSetto take the complement of.- Returns:
- the complement of x
-
containsElements
public boolean containsElements()Returns whether the set contains elements.- Returns:
- Whether the set is non-empty.
-
numIntervals
public int numIntervals()Returns the number of intervals.- Returns:
- number of intervals.
-
getIntervals
-
intervalIterator
-
getCaseless
Create a caseless version of this charset.The caseless version contains all characters of this char set, and additionally all lower/upper/title case variants of the characters in this set.
- Parameters:
unicodeProperties- The Unicode Properties to use when generating caseless equivalence classes.- Returns:
- a caseless copy of this set
-
toString
-
copyOf
Creates a IntCharSet from an existing IntCharSet.- Returns:
- a (deep) copy of the char set.
-
size
public int size()Computes the size of this set.- Returns:
- how many elements are contained in this set
-
invariants
boolean invariants()Checks the invariants of this object.- Returns:
- true when the invariants of this objects hold.
-
isSubSet
Very slow but elementary method to determine whether s1 is a subset of s2. For assertions in debugging/testing only.- Parameters:
s1- the first IntCharSets2- the second IntCharSet- Returns:
- true iff s1 is a subset of s2
-
iterator
-
getFirstInterval
Interval getFirstInterval()
-