Package com.google.common.base
Class SmallCharMatcher
- java.lang.Object
-
- com.google.common.base.CharMatcher
-
- com.google.common.base.CharMatcher.FastMatcher
-
- com.google.common.base.CharMatcher.NamedFastMatcher
-
- com.google.common.base.SmallCharMatcher
-
- All Implemented Interfaces:
Predicate<java.lang.Character>
,java.util.function.Predicate<java.lang.Character>
@GwtIncompatible final class SmallCharMatcher extends CharMatcher.NamedFastMatcher
An immutable version of CharMatcher for smallish sets of characters that uses a hash table with linear probing to check for matches.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.base.CharMatcher
CharMatcher.FastMatcher, CharMatcher.NamedFastMatcher, CharMatcher.NegatedFastMatcher, CharMatcher.Whitespace
-
-
Field Summary
Fields Modifier and Type Field Description private static int
C1
private static int
C2
private boolean
containsZero
private static double
DESIRED_LOAD_FACTOR
private long
filter
(package private) static int
MAX_SIZE
private char[]
table
-
Fields inherited from class com.google.common.base.CharMatcher
ANY, ASCII, BREAKING_WHITESPACE, DIGIT, INVISIBLE, JAVA_DIGIT, JAVA_ISO_CONTROL, JAVA_LETTER, JAVA_LETTER_OR_DIGIT, JAVA_LOWER_CASE, JAVA_UPPER_CASE, NONE, SINGLE_WIDTH, WHITESPACE
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SmallCharMatcher(char[] table, long filter, boolean containsZero, java.lang.String description)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
checkFilter(int c)
(package private) static int
chooseTableSize(int setSize)
Returns an array size suitable for the backing array of a hash table that uses open addressing with linear probing in its implementation.(package private) static CharMatcher
from(java.util.BitSet chars, java.lang.String description)
boolean
matches(char c)
Determines a true or false value for the given character.(package private) void
setBits(java.util.BitSet table)
Sets bits intable
matched by this matcher.(package private) static int
smear(int hashCode)
-
Methods inherited from class com.google.common.base.CharMatcher.NamedFastMatcher
toString
-
Methods inherited from class com.google.common.base.CharMatcher.FastMatcher
negate, precomputed
-
Methods inherited from class com.google.common.base.CharMatcher
and, any, anyOf, apply, ascii, breakingWhitespace, collapseFrom, countIn, digit, forPredicate, indexIn, indexIn, inRange, invisible, is, isNot, javaDigit, javaIsoControl, javaLetter, javaLetterOrDigit, javaLowerCase, javaUpperCase, lastIndexIn, matchesAllOf, matchesAnyOf, matchesNoneOf, none, noneOf, or, precomputedInternal, removeFrom, replaceFrom, replaceFrom, retainFrom, singleWidth, trimAndCollapseFrom, trimFrom, trimLeadingFrom, trimTrailingFrom, whitespace
-
-
-
-
Field Detail
-
MAX_SIZE
static final int MAX_SIZE
- See Also:
- Constant Field Values
-
table
private final char[] table
-
containsZero
private final boolean containsZero
-
filter
private final long filter
-
C1
private static final int C1
- See Also:
- Constant Field Values
-
C2
private static final int C2
- See Also:
- Constant Field Values
-
DESIRED_LOAD_FACTOR
private static final double DESIRED_LOAD_FACTOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
smear
static int smear(int hashCode)
-
checkFilter
private boolean checkFilter(int c)
-
chooseTableSize
static int chooseTableSize(int setSize)
Returns an array size suitable for the backing array of a hash table that uses open addressing with linear probing in its implementation. The returned size is the smallest power of two that can hold setSize elements with the desired load factor.
-
from
static CharMatcher from(java.util.BitSet chars, java.lang.String description)
-
matches
public boolean matches(char c)
Description copied from class:CharMatcher
Determines a true or false value for the given character.- Specified by:
matches
in classCharMatcher
-
setBits
void setBits(java.util.BitSet table)
Description copied from class:CharMatcher
Sets bits intable
matched by this matcher.- Overrides:
setBits
in classCharMatcher
-
-