Class CharArrayMap<V>

  • All Implemented Interfaces:
    java.util.Map<java.lang.Object,​V>

    public class CharArrayMap<V>
    extends java.util.AbstractMap<java.lang.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.

    You must specify the required Version compatibility when creating CharArrayMap:

    • As of 3.1, supplementary characters are properly lowercased.
    Before 3.1 supplementary characters could not be lowercased correctly due to the lack of Unicode 4 support in JDK 1.4. To use instances of CharArrayMap with the behavior before Lucene 3.1 pass a Version < 3.1 to the constructors.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  CharArrayMap.EntryIterator
      public iterator class so efficient methods are exposed to users
      class  CharArrayMap.EntrySet
      public EntrySet class so efficient methods are exposed to users
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      CharArrayMap​(Version matchVersion, int startSize, boolean ignoreCase)
      Create map with enough capacity to hold startSize terms
      CharArrayMap​(Version matchVersion, java.util.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)
      true if the len chars of text starting at off are in the keySet()
      boolean containsKey​(java.lang.CharSequence cs)
      true if the CharSequence is in the keySet()
      boolean containsKey​(java.lang.Object o)  
      static <V> CharArrayMap<V> copy​(Version matchVersion, java.util.Map<?,​? extends V> map)
      Returns a copy of the given map as a CharArrayMap.
      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 of len chars of text starting at off
      V get​(java.lang.CharSequence cs)
      returns the value of the mapping of the chars inside this CharSequence
      V get​(java.lang.Object o)  
      CharArraySet keySet()
      Returns an CharArraySet view on the map's keys.
      V put​(char[] text, V value)
      Add the given mapping.
      V put​(java.lang.CharSequence text, V value)
      Add the given mapping.
      V put​(java.lang.Object o, V value)  
      V put​(java.lang.String text, V value)
      Add the given mapping.
      V remove​(java.lang.Object key)  
      int size()  
      java.lang.String toString()  
      static <V> CharArrayMap<V> unmodifiableMap​(CharArrayMap<V> map)
      Returns an unmodifiable CharArrayMap.
      • Methods inherited from class java.util.AbstractMap

        containsValue, equals, hashCode, isEmpty, putAll, values
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • CharArrayMap

        public CharArrayMap​(Version matchVersion,
                            int startSize,
                            boolean ignoreCase)
        Create map with enough capacity to hold startSize terms
        Parameters:
        matchVersion - compatibility match version see Version note above for details.
        startSize - the initial capacity
        ignoreCase - false if and only if the set should be case sensitive otherwise true.
      • CharArrayMap

        public CharArrayMap​(Version matchVersion,
                            java.util.Map<?,​? extends V> c,
                            boolean ignoreCase)
        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 copied
        ignoreCase - false if and only if the set should be case sensitive otherwise true.
    • Method Detail

      • clear

        public void clear()
        Clears all entries in this map. This method is supported for reusing, but not Map.remove(java.lang.Object).
        Specified by:
        clear in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        clear in class java.util.AbstractMap<java.lang.Object,​V>
      • containsKey

        public boolean containsKey​(char[] text,
                                   int off,
                                   int len)
        true if the len chars of text starting at off are in the keySet()
      • containsKey

        public boolean containsKey​(java.lang.CharSequence cs)
        true if the CharSequence is in the keySet()
      • containsKey

        public boolean containsKey​(java.lang.Object o)
        Specified by:
        containsKey in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        containsKey in class java.util.AbstractMap<java.lang.Object,​V>
      • get

        public V get​(char[] text,
                     int off,
                     int len)
        returns the value of the mapping of len chars of text starting at off
      • get

        public V get​(java.lang.CharSequence cs)
        returns the value of the mapping of the chars inside this CharSequence
      • get

        public V get​(java.lang.Object o)
        Specified by:
        get in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        get in class java.util.AbstractMap<java.lang.Object,​V>
      • put

        public V put​(java.lang.CharSequence text,
                     V value)
        Add the given mapping.
      • put

        public V put​(java.lang.Object o,
                     V value)
        Specified by:
        put in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        put in class java.util.AbstractMap<java.lang.Object,​V>
      • put

        public V put​(java.lang.String 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.
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        remove in class java.util.AbstractMap<java.lang.Object,​V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        size in class java.util.AbstractMap<java.lang.Object,​V>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractMap<java.lang.Object,​V>
      • entrySet

        public final CharArrayMap.EntrySet entrySet()
        Specified by:
        entrySet in interface java.util.Map<java.lang.Object,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<java.lang.Object,​V>
      • keySet

        public final CharArraySet keySet()
        Returns an CharArraySet view on the map's keys. The set will use the same matchVersion as this map.
        Specified by:
        keySet in interface java.util.Map<java.lang.Object,​V>
        Overrides:
        keySet in class java.util.AbstractMap<java.lang.Object,​V>
      • unmodifiableMap

        public static <V> CharArrayMap<V> unmodifiableMap​(CharArrayMap<V> map)
        Returns an unmodifiable CharArrayMap. 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:
        java.lang.NullPointerException - if the given map is null.
      • emptyMap

        public static <V> CharArrayMap<V> emptyMap()
        Returns an empty, unmodifiable map.