Package org.apache.lucene.analysis.util
Class CharArrayMap<V>
A simple class that stores key Strings as char[]'s in a
hash table. Note that this is not a general purpose
class. For example, it cannot remove items from the
map, nor does it resize its hash table to be smaller,
etc. It is designed to be quick to retrieve items
by char[] keys without the necessity of converting
to a String first.
You must specify the required Version
compatibility when creating CharArrayMap:
- As of 3.1, supplementary characters are properly lowercased.
CharArrayMap with the behavior before Lucene
3.1 pass a Version < 3.1 to the constructors.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclasspublic iterator class so efficient methods are exposed to usersfinal classpublic EntrySet class so efficient methods are exposed to usersNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionCharArrayMap(Version matchVersion, int startSize, boolean ignoreCase) Create map with enough capacity to hold startSize termsCharArrayMap(Version matchVersion, Map<?, ? extends V> c, boolean ignoreCase) Creates a map from the mappings in another map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all entries in this map.booleancontainsKey(char[] text, int off, int len) booleantrue if theCharSequenceis in thekeySet()booleanstatic <V> CharArrayMap<V> Returns a copy of the given map as aCharArrayMap.static <V> CharArrayMap<V> emptyMap()Returns an empty, unmodifiable map.final CharArrayMap<V>.EntrySetentrySet()get(char[] text, int off, int len) returns the value of the mapping oflenchars oftextstarting atoffget(CharSequence cs) returns the value of the mapping of the chars inside thisCharSequencefinal CharArraySetkeySet()Returns anCharArraySetview on the map's keys.Add the given mapping.put(CharSequence text, V value) Add the given mapping.Add the given mapping.intsize()toString()static <V> CharArrayMap<V> unmodifiableMap(CharArrayMap<V> map) Returns an unmodifiableCharArrayMap.Methods inherited from class java.util.AbstractMap
containsValue, equals, hashCode, isEmpty, putAll, valuesMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CharArrayMap
Create map with enough capacity to hold startSize terms- Parameters:
matchVersion- compatibility match version see Version note above for details.startSize- the initial capacityignoreCase-falseif and only if the set should be case sensitive otherwisetrue.
-
CharArrayMap
Creates a map from the mappings in another map.- Parameters:
matchVersion- compatibility match version see Version note above for details.c- a map whose mappings to be copiedignoreCase-falseif and only if the set should be case sensitive otherwisetrue.
-
-
Method Details
-
clear
public void clear()Clears all entries in this map. This method is supported for reusing, but notMap.remove(java.lang.Object). -
containsKey
public boolean containsKey(char[] text, int off, int len) -
containsKey
true if theCharSequenceis in thekeySet() -
containsKey
- Specified by:
containsKeyin interfaceMap<Object,V> - Overrides:
containsKeyin classAbstractMap<Object,V>
-
get
returns the value of the mapping oflenchars oftextstarting atoff -
get
returns the value of the mapping of the chars inside thisCharSequence -
get
-
put
Add the given mapping. -
put
-
put
Add the given mapping. -
put
Add the given mapping. If ignoreCase is true for this Set, the text array will be directly modified. The user should never modify this text array after calling this method. -
remove
-
size
public int size() -
toString
- Overrides:
toStringin classAbstractMap<Object,V>
-
entrySet
-
keySet
Returns anCharArraySetview on the map's keys. The set will use the samematchVersionas this map. -
unmodifiableMap
Returns an unmodifiableCharArrayMap. This allows to provide unmodifiable views of internal map for "read-only" use.- Parameters:
map- a map for which the unmodifiable map is returned.- Returns:
- an new unmodifiable
CharArrayMap. - Throws:
NullPointerException- if the given map isnull.
-
copy
Returns a copy of the given map as aCharArrayMap. If the given map is aCharArrayMapthe ignoreCase property will be preserved.Note: If you intend to create a copy of another
CharArrayMapwhere theVersionof the source map differs from its copyCharArrayMap(Version, Map, boolean)should be used instead. Thecopy(Version, Map)will preserve theVersionof the source map it is an instance ofCharArrayMap.- Parameters:
matchVersion- compatibility match version see Version note above for details. This argument will be ignored if the given map is aCharArrayMap.map- a map to copy- Returns:
- a copy of the given map as a
CharArrayMap. If the given map is aCharArrayMapthe ignoreCase property as well as the matchVersion will be of the given map will be preserved.
-
emptyMap
Returns an empty, unmodifiable map.
-