Class CharFilter
java.lang.Object
com.github.tommyettinger.ds.CharFilter
A small class that holds two functional-interface values used for filtering and editing characters, and a name they
are associated with. Every time a CharFilter is constructed, it is registered internally, so it can be looked up at a
later time by name, using
Any CharFilter can be used as a factory to create
Any CharFilter can be also used as a factory to create
A CharFilter can be used to produce high-quality non-cryptographic hashes of char arrays, Strings, and other CharSequences (including
If you target GWT, be aware that several built-in JDK methods for handling chars may work differently in HTML than on desktop, Android, or other platforms. In particular,
get(String) or getOrDefault(String, CharFilter). Actually obtaining
CharFilter objects is done with getOrCreate(String, CharPredicate, CharToCharFunction), which tries to get
an existing CharFilter first, and if it can't find one, then it creates, registers, and returns one. A suggested
practice for names is to describe the filter's effects first, if any, followed by the editor's effects. A typical
filter might only allow letter chars through, and would convert them to upper-case so that they can (almost always)
be treated as case-insensitive. This could use
com.github.tommyettinger.ds.support.util.CharPredicates.IS_LETTER (or a method reference to
Character.isLetter(char)) for the filter, Casing.caseUp(char) (or
Character.toUpperCase(char)) for the editor, and could be named "LetterOnlyCaseInsensitive".
Any CharFilter can be used as a factory to create
FilteredStringSet and FilteredStringOrderedSet
collections as if using their ObjectSet.with() static method and this CharFilter. These use the
makeSet() and makeOrderedSet() methods, which can take 0-8 String parameters without allocating,
or any number of String parameters if given an array or varargs.
Any CharFilter can be also used as a factory to create
FilteredStringMap and FilteredStringOrderedMap
collections as if using their ObjectObjectMap.with() static method and this CharFilter. These use the
makeMap() and makeOrderedMap() methods, which can take 0-4 String-V pairs without allocating,
or one or more String-V pairs if given an array or varargs.
A CharFilter can be used to produce high-quality non-cryptographic hashes of char arrays, Strings, and other CharSequences (including
CharList, CharBag, and CharDeque), producing either 32-bit or 64-bit
hashes. These take a long seed and optionally start and length parameters; they use
hash(long, char[]), hash64(long, char[]), and their overloads. Predefined functions are also
provided with Hasher.SeededHashFunction and Hasher.SeededHashFunction64 types, such as
stringHash, stringArrayHash, and stringArray2DHash, to handle multidimensional arrays.
All hash functions respect the filter and editor of the CharFilter; they won't consider any char that
the filter returns false for, and they run each char through the editor
after passing the filter but before incorporating it into the hash result.
If you target GWT, be aware that several built-in JDK methods for handling chars may work differently in HTML than on desktop, Android, or other platforms. In particular,
Character.isLetter(char) will not work on most Unicode
chars on GWT, so you need another way to handle checks like that.
com.github.tommyettinger.ds.support.util.CharPredicates.IS_LETTER is a CharPredicate you can use instead of
isLetter on any platform, and acts as Character.isLetter(char) does on Java 25, but on all Java versions and
target platforms (including GWT). Other fields in CharPredicates may also be useful, and you can create your own
CharBitSet or CharBitSetFixedSize objects to serve as predefined predicates that look up a char in an
uncompressed bit set.-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal com.github.tommyettinger.digital.Hasher.SeededHashFunction<char[][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<char[][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<char[][][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<char[][][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<char[]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<char[]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence[][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence[][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence[][][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence[][][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence[]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence[]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence> final com.github.tommyettinger.function.CharToCharFunctionA CharToCharFunction that will take a char from a key String and return a potentially different char.final com.github.tommyettinger.function.CharPredicateA CharPredicate that should return true iff a character should be considered for equality/hashing.final StringThe unique identifying name for this combination of filter and editor.final com.github.tommyettinger.digital.Hasher.SeededHashFunction<String[][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String[][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<String[][][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String[][][]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<String[]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String[]> final com.github.tommyettinger.digital.Hasher.SeededHashFunction<String> final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedCharFilter(String name, com.github.tommyettinger.function.CharPredicate filter, com.github.tommyettinger.function.CharToCharFunction editor) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if a CharFilter is registered toname, returning true if one is, or false otherwise.booleanstatic CharFilterGets the CharFilter registered toname, or null if none exists.com.github.tommyettinger.function.CharToCharFunctioncom.github.tommyettinger.function.CharPredicategetName()static CharFiltergetOrCreate(String name, com.github.tommyettinger.function.CharPredicate filter, com.github.tommyettinger.function.CharToCharFunction editor) Tries to get an existing CharFilter known byname, and if one exists, this returns that CharFilter.static CharFiltergetOrDefault(String name, CharFilter defaultValue) Gets the CharFilter registered toname, ordefaultValueif none exists.inthash(long seed, char[] data) inthash(long seed, char[] data, int start, int length) inthash(long seed, CharSequence data) inthash(long seed, CharSequence data, int start, int length) intintlonghash64(long seed, char[] data) longhash64(long seed, char[] data, int start, int length) longhash64(long seed, CharSequence data) longhash64(long seed, CharSequence data, int start, int length) longlonginthashCode()<V> FilteredStringMap<V> makeMap()Constructs an empty map given just a CharFilter.<V> FilteredStringMap<V> Constructs a single-entry map given a CharFilter, one key and one value.<V> FilteredStringMap<V> Constructs a map given a CharFilter, then alternating keys and values.<V> FilteredStringMap<V> Constructs a single-entry map given a CharFilter and two key-value pairs.<V> FilteredStringMap<V> Constructs a single-entry map given a CharFilter and three key-value pairs.<V> FilteredStringMap<V> Constructs a single-entry map given a CharFilter and four key-value pairs.<V> FilteredStringOrderedMap<V> Constructs an empty ordered map given just a CharFilter.<V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0) Constructs a single-entry ordered map given a CharFilter, one key and one value.<V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0, Object... rest) Constructs a ordered map given a CharFilter, then alternating keys and values.<V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0, String key1, V value1) Constructs a single-entry ordered map given a CharFilter and two key-value pairs.<V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0, String key1, V value1, String key2, V value2) Constructs a single-entry ordered map given a CharFilter and three key-value pairs.<V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0, String key1, V value1, String key2, V value2, String key3, V value3) Constructs a single-entry ordered map given a CharFilter and four key-value pairs.Constructs an empty ordered set using this CharFilter.makeOrderedSet(String item) Creates a new FilteredStringOrderedSet that holds only the given item, but can be resized.makeOrderedSet(String... varargs) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.makeOrderedSet(String item0, String item1) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.makeOrderedSet(String item0, String item1, String item2) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.makeOrderedSet(String item0, String item1, String item2, String item3) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.makeOrderedSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.makeOrderedSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6, String item7) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized.makeSet()Constructs an empty set using this CharFilter.Creates a new FilteredStringSet that holds only the given item, but can be resized.Creates a new FilteredStringSet that holds only the given items, but can be resized.Creates a new FilteredStringSet that holds only the given items, but can be resized.Creates a new FilteredStringSet that holds only the given items, but can be resized.Creates a new FilteredStringSet that holds only the given items, but can be resized.Creates a new FilteredStringSet that holds only the given items, but can be resized.Creates a new FilteredStringSet that holds only the given items, but can be resized.makeSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6) Creates a new FilteredStringSet that holds only the given items, but can be resized.makeSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6, String item7) Creates a new FilteredStringSet that holds only the given items, but can be resized.toString()
-
Field Details
-
name
The unique identifying name for this combination of filter and editor. -
filter
public final com.github.tommyettinger.function.CharPredicate filterA CharPredicate that should return true iff a character should be considered for equality/hashing. -
editor
public final com.github.tommyettinger.function.CharToCharFunction editorA CharToCharFunction that will take a char from a key String and return a potentially different char. -
charArrayHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<char[]> charArrayHash64 -
charSequenceHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence> charSequenceHash64 -
stringHash64
-
charArray2DHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<char[][]> charArray2DHash64 -
charSequenceArrayHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence[]> charSequenceArrayHash64 -
stringArrayHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String[]> stringArrayHash64 -
charArray3DHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<char[][][]> charArray3DHash64 -
charSequenceArray2DHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence[][]> charSequenceArray2DHash64 -
stringArray2DHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String[][]> stringArray2DHash64 -
charSequenceArray3DHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<CharSequence[][][]> charSequenceArray3DHash64 -
stringArray3DHash64
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction64<String[][][]> stringArray3DHash64 -
charArrayHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<char[]> charArrayHash -
charSequenceHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence> charSequenceHash -
stringHash
-
charArray2DHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<char[][]> charArray2DHash -
charSequenceArrayHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence[]> charSequenceArrayHash -
stringArrayHash
-
charArray3DHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<char[][][]> charArray3DHash -
charSequenceArray2DHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence[][]> charSequenceArray2DHash -
stringArray2DHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<String[][]> stringArray2DHash -
charSequenceArray3DHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<CharSequence[][][]> charSequenceArray3DHash -
stringArray3DHash
public final com.github.tommyettinger.digital.Hasher.SeededHashFunction<String[][][]> stringArray3DHash
-
-
Constructor Details
-
CharFilter
protected CharFilter() -
CharFilter
protected CharFilter(String name, com.github.tommyettinger.function.CharPredicate filter, com.github.tommyettinger.function.CharToCharFunction editor)
-
-
Method Details
-
equals
-
hashCode
-
toString
-
getName
-
getFilter
public com.github.tommyettinger.function.CharPredicate getFilter() -
getEditor
public com.github.tommyettinger.function.CharToCharFunction getEditor() -
getOrCreate
public static CharFilter getOrCreate(String name, com.github.tommyettinger.function.CharPredicate filter, com.github.tommyettinger.function.CharToCharFunction editor) Tries to get an existing CharFilter known byname, and if one exists, this returns that CharFilter. Otherwise, this will construct and return a new CharFilter with the given name, filter, and editor, registering it in the process.- Parameters:
name- the String name to look up, or to register by if none was foundfilter- a CharPredicate that should return true iff a character should be considered for equality/hashingeditor- a CharToCharFunction that will take a char from a key String and return a potentially different char- Returns:
- a CharFilter, either one that already exists by the given name, or a newly-registered one that was just created
-
contains
Checks if a CharFilter is registered toname, returning true if one is, or false otherwise.- Parameters:
name- the name to look up- Returns:
- true if a CharFilter is registered by
name, or false otherwise
-
get
Gets the CharFilter registered toname, or null if none exists.- Parameters:
name- the name to look up- Returns:
- a registered CharFilter or null
-
getOrDefault
Gets the CharFilter registered toname, ordefaultValueif none exists.- Parameters:
name- the name to look updefaultValue- a CharFilter to return if none was found; may be null- Returns:
- a registered CharFilter or
defaultValue
-
makeSet
Constructs an empty set using this CharFilter. This is usually less useful than just using the constructor, but can be handy in some code-generation scenarios when you don't know how many arguments you will have.- Returns:
- a new set containing nothing
-
makeSet
Creates a new FilteredStringSet that holds only the given item, but can be resized. Uses this CharFilter in the new set.- Parameters:
item- one String item- Returns:
- a new FilteredStringSet that holds the given item
-
makeSet
Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
public FilteredStringSet makeSet(String item0, String item1, String item2, String item3, String item4) Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
public FilteredStringSet makeSet(String item0, String item1, String item2, String item3, String item4, String item5) Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String itemitem5- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
public FilteredStringSet makeSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6) Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String itemitem5- a String itemitem6- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
public FilteredStringSet makeSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6, String item7) Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String itemitem5- a String itemitem6- a String item- Returns:
- a new FilteredStringSet that holds the given items
-
makeSet
Creates a new FilteredStringSet that holds only the given items, but can be resized. Uses this CharFilter in the new set. This overload will only be used when an array is supplied or if varargs are used and there are 9 or more arguments.- Parameters:
varargs- a String varargs or String array; remember that varargs allocate- Returns:
- a new FilteredStringSet that holds the given items
-
makeOrderedSet
Constructs an empty ordered set using this CharFilter. This is usually less useful than just using the constructor, but can be handy in some code-generation scenarios when you don't know how many arguments you will have.- Returns:
- a new ordered set containing nothing
-
makeOrderedSet
Creates a new FilteredStringOrderedSet that holds only the given item, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item- one String item- Returns:
- a new FilteredStringOrderedSet that holds the given item
-
makeOrderedSet
Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
public FilteredStringOrderedSet makeOrderedSet(String item0, String item1, String item2, String item3) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
public FilteredStringOrderedSet makeOrderedSet(String item0, String item1, String item2, String item3, String item4) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
public FilteredStringOrderedSet makeOrderedSet(String item0, String item1, String item2, String item3, String item4, String item5) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String itemitem5- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
public FilteredStringOrderedSet makeOrderedSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String itemitem5- a String itemitem6- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
public FilteredStringOrderedSet makeOrderedSet(String item0, String item1, String item2, String item3, String item4, String item5, String item6, String item7) Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set.- Parameters:
item0- a String itemitem1- a String itemitem2- a String itemitem3- a String itemitem4- a String itemitem5- a String itemitem6- a String item- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeOrderedSet
Creates a new FilteredStringOrderedSet that holds only the given items, but can be resized. Uses this CharFilter in the new ordered set. This overload will only be used when an array is supplied or if varargs are used and there are 9 or more arguments.- Parameters:
varargs- a String varargs or String array; remember that varargs allocate- Returns:
- a new FilteredStringOrderedSet that holds the given items
-
makeMap
Constructs an empty map given just a CharFilter. This is usually less useful than just using the constructor, but can be handy in some code-generation scenarios when you don't know how many arguments you will have.- Type Parameters:
V- the type of values- Returns:
- a new map containing nothing
-
makeMap
Constructs a single-entry map given a CharFilter, one key and one value. This is mostly useful as an optimization formakeMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- the first and only keyvalue0- the first and only value- Returns:
- a new map containing just the entry mapping key0 to value0
-
makeMap
Constructs a single-entry map given a CharFilter and two key-value pairs. This is mostly useful as an optimization formakeMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- a String keyvalue0- a V valuekey1- a String keyvalue1- a V value- Returns:
- a new map containing entries mapping each key to the following value
-
makeMap
public <V> FilteredStringMap<V> makeMap(String key0, V value0, String key1, V value1, String key2, V value2) Constructs a single-entry map given a CharFilter and three key-value pairs. This is mostly useful as an optimization formakeMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- a String keyvalue0- a V valuekey1- a String keyvalue1- a V valuekey2- a String keyvalue2- a V value- Returns:
- a new map containing entries mapping each key to the following value
-
makeMap
public <V> FilteredStringMap<V> makeMap(String key0, V value0, String key1, V value1, String key2, V value2, String key3, V value3) Constructs a single-entry map given a CharFilter and four key-value pairs. This is mostly useful as an optimization formakeMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- a String keyvalue0- a V valuekey1- a String keyvalue1- a V valuekey2- a String keyvalue2- a V valuekey3- a String keyvalue3- a V value- Returns:
- a new map containing entries mapping each key to the following value
-
makeMap
Constructs a map given a CharFilter, then alternating keys and values. This can be useful in some code-generation scenarios, or when you want to make a map conveniently by-hand and have it populated at the start. You can also useFilteredStringMap(CharFilter, String[], Object[]), which takes all keys and then all values. This needs all keys to have the same type and all values to have the same type, because it gets those types from the first key parameter and first value parameter. Any keys that don't have String as their type or values that don't have V as their type have that entry skipped.- Type Parameters:
V- the type of values, inferred from value0- Parameters:
key0- the first key; will be used to determine the type of all keysvalue0- the first value; will be used to determine the type of all valuesrest- an array or varargs of alternating String, V, String, V... elements- Returns:
- a new map containing the given keys and values
-
makeOrderedMap
Constructs an empty ordered map given just a CharFilter. This is usually less useful than just using the constructor, but can be handy in some code-generation scenarios when you don't know how many arguments you will have.- Type Parameters:
V- the type of values- Returns:
- a new ordered map containing nothing
-
makeOrderedMap
Constructs a single-entry ordered map given a CharFilter, one key and one value. This is mostly useful as an optimization formakeOrderedMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- the first and only keyvalue0- the first and only value- Returns:
- a new ordered map containing just the entry mapping key0 to value0
-
makeOrderedMap
Constructs a single-entry ordered map given a CharFilter and two key-value pairs. This is mostly useful as an optimization formakeOrderedMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- a String keyvalue0- a V valuekey1- a String keyvalue1- a V value- Returns:
- a new ordered map containing entries mapping each key to the following value
-
makeOrderedMap
public <V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0, String key1, V value1, String key2, V value2) Constructs a single-entry ordered map given a CharFilter and three key-value pairs. This is mostly useful as an optimization formakeOrderedMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- a String keyvalue0- a V valuekey1- a String keyvalue1- a V valuekey2- a String keyvalue2- a V value- Returns:
- a new ordered map containing entries mapping each key to the following value
-
makeOrderedMap
public <V> FilteredStringOrderedMap<V> makeOrderedMap(String key0, V value0, String key1, V value1, String key2, V value2, String key3, V value3) Constructs a single-entry ordered map given a CharFilter and four key-value pairs. This is mostly useful as an optimization formakeOrderedMap(String, Object, Object...)when there's no "rest" of the keys or values.- Type Parameters:
V- the type of value0- Parameters:
key0- a String keyvalue0- a V valuekey1- a String keyvalue1- a V valuekey2- a String keyvalue2- a V valuekey3- a String keyvalue3- a V value- Returns:
- a new ordered map containing entries mapping each key to the following value
-
makeOrderedMap
Constructs a ordered map given a CharFilter, then alternating keys and values. This can be useful in some code-generation scenarios, or when you want to make a ordered map conveniently by-hand and have it populated at the start. You can also useFilteredStringOrderedMap(CharFilter, String[], Object[]), which takes all keys and then all values. This needs all keys to have the same type and all values to have the same type, because it gets those types from the first key parameter and first value parameter. Any keys that don't have String as their type or values that don't have V as their type have that entry skipped.- Type Parameters:
V- the type of values, inferred from value0- Parameters:
key0- the first key; will be used to determine the type of all keysvalue0- the first value; will be used to determine the type of all valuesrest- an array or varargs of alternating String, V, String, V... elements- Returns:
- a new ordered map containing the given keys and values
-
hash
public int hash(long seed, char[] data) Hashes a char array, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 32-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the char array to hash- Returns:
- a 32-bit hash of data
-
hash
public int hash(long seed, char[] data, int start, int length) Hashes a section of a char array, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 32-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the char array to hashstart- the start indexlength- how many items to hash (this will hash fewer if there aren't enough items in the array)- Returns:
- a 32-bit hash of data
-
hash
Hashes a CharSequence, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 32-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String or other CharSequence to hash- Returns:
- a 32-bit hash of data
-
hash
Hashes a section of a CharSequence, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 32-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String or other CharSequence to hashstart- the start indexlength- how many items to hash (this will hash fewer if there aren't enough items in the CharSequence)- Returns:
- a 32-bit hash of data
-
hash
Hashes a String, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 32-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String to hash- Returns:
- a 32-bit hash of data
-
hash
Hashes a section of a String, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 32-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String to hashstart- the start indexlength- how many items to hash (this will hash fewer if there aren't enough items in the CharSequence)- Returns:
- a 32-bit hash of data
-
hash64
public long hash64(long seed, char[] data) Hashes a char array, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 64-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT64_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the char array to hash- Returns:
- a 64-bit hash of data
-
hash64
public long hash64(long seed, char[] data, int start, int length) Hashes a section of a char array, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 64-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT64_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the char array to hashstart- the start indexlength- how many items to hash (this will hash fewer if there aren't enough items in the array)- Returns:
- a 64-bit hash of data
-
hash64
Hashes a CharSequence, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 64-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT64_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String or other CharSequence to hash- Returns:
- a 64-bit hash of data
-
hash64
Hashes a section of a CharSequence, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 64-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT64_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String or other CharSequence to hashstart- the start indexlength- how many items to hash (this will hash fewer if there aren't enough items in the CharSequence)- Returns:
- a 64-bit hash of data
-
hash64
Hashes a String, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 64-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT64_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String to hash- Returns:
- a 64-bit hash of data
-
hash64
Hashes a section of a String, ignoring any chars that thefilterdoesn't return true for, and potentially changing chars using theeditoronly during hashing (not permanently). Gets a 64-bit hash. Uses 64-bit math so this behaves correctly, though slowly, on GWT.
Based on Sokolov Yura's (funny_falcon's) GoodOAAT hash for bytes, but made to work on Java's 16-bit chars instead. GoodOAAT is MIT-licensed. Like GoodOAAT, this is non-multiplicative.
This hash passes SMHasher 3 testing. It is called "PairAAT64_C" in the test repo.- Parameters:
seed- any change to the seed should change the hashes of non-null, non-empty datadata- the String to hashstart- the start indexlength- how many items to hash (this will hash fewer if there aren't enough items in the CharSequence)- Returns:
- a 64-bit hash of data
-