Class HybridBitSetMatcher
java.lang.Object
com.oracle.truffle.regex.tregex.matchers.CharMatcher
com.oracle.truffle.regex.tregex.matchers.InvertibleCharMatcher
com.oracle.truffle.regex.tregex.matchers.HybridBitSetMatcher
Character matcher that compiles to a binary search in a sorted list of ranges, like
RangeTreeMatcher, but replaces some subtrees with bit-set matches. Specifically, if the
character set contains many short ranges that differ only in the lowest byte, those ranges are
converted to a bit-set, which is checked when the binary search finds that the given character is
in the byte range denoted by the bit set. The threshold for bit-set conversion is defined by
TRegexOptions.TRegexRangeToBitSetConversionThreshold.
Example:
Character set: [0x02, 0x04, 0x06, 0x1000, 0x1020-0x1030] Resulting Hybrid matcher with threshold = 3: - ranges: [0x02-0x06, 0x1000, 0x1020-0x1030] - bit-sets: [[0x02, 0x04, 0x06], null, null ]
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic HybridBitSetMatchercreate(boolean invert, CompressedCodePointSet ccps) intConservatively estimate the equivalent number of integer comparisons of callingCharMatcher.match(int).booleanmatch(int c) Check if a given code point matches thisCharMatcher.toString()Methods inherited from class com.oracle.truffle.regex.tregex.matchers.InvertibleCharMatcher
modifiersToString, result, result
-
Method Details
-
create
-
match
public boolean match(int c) Description copied from class:CharMatcherCheck if a given code point matches thisCharMatcher.- Specified by:
matchin classCharMatcher- Parameters:
c- any code point.- Returns:
trueif the character matches.- See Also:
-
estimatedCost
public int estimatedCost()Description copied from class:CharMatcherConservatively estimate the equivalent number of integer comparisons of callingCharMatcher.match(int).- Specified by:
estimatedCostin classCharMatcher- Returns:
- the number of integer comparisons one call to
CharMatcher.match(int)is roughly equivalent to. Array loads are treated as two comparisons.
-
toString
-