Package org.apache.lucene.analysis
Class CharArrayMap<V>
- java.lang.Object
-
- java.util.AbstractMap<Object,V>
-
- org.apache.lucene.analysis.CharArrayMap<V>
-
public class CharArrayMap<V> extends AbstractMap<Object,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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CharArrayMap.EntryIterator
public iterator class so efficient methods are exposed to usersclass
CharArrayMap.EntrySet
public EntrySet class so efficient methods are exposed to users-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description CharArrayMap(int startSize, boolean ignoreCase)
Create map with enough capacity to hold startSize termsCharArrayMap(Map<?,? extends V> c, boolean ignoreCase)
Creates a map from the mappings in another map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears all entries in this map.boolean
containsKey(char[] text, int off, int len)
boolean
containsKey(CharSequence cs)
true if theCharSequence
is in thekeySet()
boolean
containsKey(Object o)
static <V> CharArrayMap<V>
copy(Map<?,? extends V> map)
Returns a copy of the given map as aCharArrayMap
.static <V> CharArrayMap<V>
emptyMap()
Returns an empty, unmodifiable map.CharArrayMap.EntrySet
entrySet()
V
get(char[] text, int off, int len)
returns the value of the mapping oflen
chars oftext
starting atoff
V
get(CharSequence cs)
returns the value of the mapping of the chars inside thisCharSequence
V
get(Object o)
CharArraySet
keySet()
Returns anCharArraySet
view on the map's keys.V
put(char[] text, V value)
Add the given mapping.V
put(CharSequence text, V value)
Add the given mapping.V
put(Object o, V value)
V
put(String text, V value)
Add the given mapping.V
remove(Object key)
int
size()
String
toString()
static <V> CharArrayMap<V>
unmodifiableMap(CharArrayMap<V> map)
Returns an unmodifiableCharArrayMap
.-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
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
public boolean containsKey(CharSequence cs)
true if theCharSequence
is in thekeySet()
-
containsKey
public boolean containsKey(Object o)
- Specified by:
containsKey
in interfaceMap<Object,V>
- Overrides:
containsKey
in classAbstractMap<Object,V>
-
get
public V get(char[] text, int off, int len)
returns the value of the mapping oflen
chars oftext
starting atoff
-
get
public V get(CharSequence cs)
returns the value of the mapping of the chars inside thisCharSequence
-
put
public V put(CharSequence text, V value)
Add the given mapping.
-
put
public V put(char[] text, V value)
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.
-
size
public int size()
-
toString
public String toString()
- Overrides:
toString
in classAbstractMap<Object,V>
-
entrySet
public final CharArrayMap.EntrySet entrySet()
-
keySet
public final CharArraySet keySet()
Returns anCharArraySet
view on the map's keys. The set will use the samematchVersion
as this map.
-
unmodifiableMap
public static <V> CharArrayMap<V> unmodifiableMap(CharArrayMap<V> map)
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
public static <V> CharArrayMap<V> copy(Map<?,? extends V> map)
Returns a copy of the given map as aCharArrayMap
. If the given map is aCharArrayMap
the ignoreCase property will be preserved.- Parameters:
map
- a map to copy- Returns:
- a copy of the given map as a
CharArrayMap
. If the given map is aCharArrayMap
the ignoreCase property as well as the matchVersion will be of the given map will be preserved.
-
emptyMap
public static <V> CharArrayMap<V> emptyMap()
Returns an empty, unmodifiable map.
-
-