Readonly
maximumThe greatest character which can be element of the set.
Readonly
rangesAn array of ranges representing this character set.
The array must be guaranteed to have the following properties at all times:
min
<= max
<= this.maximum
for all ranges.min
.Returns true
if all characters in the range from 0 to this.maximum
, including 0 and this.maximum
, are in
the set.
Returns true
if this set doesn't contain any characters.
Returns the number of unique characters in the set.
The returned number will be at least 0
and at most this.maximum + 1
.
Compares this set with given set and returns an integer value describing their relation. Two equivalent set are always guaranteed to return 0.
The order defined by this function is guaranteed to be a total order. Apart from this, no other guarantees are given.
Returns whether this and the given character set are equivalent.
Two CharSet
s are equal if and only if:
Since each set of characters has a unique range representation, 2 equal CharSet
s are guaranteed to have equal
ranges.
A CharSet
and a CharRange
are equal if and only if they contain the same characters.
Returns the intersection of this set and the given set/ranges of characters.
The returned set will have the same maximum as this set.
RangeError
If the maximum of the given set differs from the maximum of this set.
Returns the complement of this set.
The returned set will have the same maximum as this set.
Returns a string representation of the ranges of this character set.
The string representation has the following rules:
min == max
will be represented by the min
character.min != max
will be represented by min
followed by ".."
followed by max
.", "
.The returned string representation will have the following format:
string = [ ranges ]
ranges = range *( ", " range )
range = +hex [ ".." +hex ]
hex = "a" | "b" | "c" | "d" | "e" | "f" | digit
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Returns a string representation of the Unicode ranges of this character set.
The primary purpose of this function is provide an easy way to get a readable representation of a Unicode or Unicode-like character set. The format is optimized for ease of reading for humans.
The format follows these rules:
empty
will be returned.all
will be returned.not
. E.g. not a b
is the character set that contains all
characters except for a and b.min-max
where min
and max
are formatted characters.a
),'-'
), orU+FF
).The returned string representation will have the following format:
string = "all" | "empty" | ranges | "not " ranges
ranges = range *( " " range )
range = char [ "-" char ]
char = literal | quoted | escape
literal = ?Printable Unicode characters?
literal = "'" ?any character? "'"
escape = "U+" +hex
hex = "A" | "B" | "C" | "D" | "E" | "F" | digit
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Returns the union of this set and all given sets and character ranges.
The returned set will have the same maximum as this set.
RangeError
If the maximum of one of the given sets differs from the maximum of this set or if the
maximum of one of the given ranges is greater than the maximum of this set.
Static
allStatic
emptyStatic
fromStatic
fromStatic
from
An immutable set of Chars represented as a sorted set of disjoint non-adjacent intervals (CharRange).
All characters in the set have to be between 0 (inclusive) and the maximum of the set (inclusive).