Class CharArraySet

  • All Implemented Interfaces:
    Iterable<Object>, Collection<Object>, Set<Object>

    public class CharArraySet
    extends AbstractSet<Object>
    A simple class that stores 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 set, nor does it resize its hash table to be smaller, etc. It is designed to be quick to test if a char[] is in the set without the necessity of converting it to a String first.

    You must specify the required Version compatibility when creating CharArraySet:

    • 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 CharArraySet with the behavior before Lucene 3.1 pass a Version < 3.1 to the constructors.

    Please note: This class implements Set but does not behave like it should in all cases. The generic type is Set<Object>, because you can add any object to it, that has a string representation. The add methods will use Object.toString() and store the result using a char[] buffer. The same behavior have the contains() methods. The iterator() returns an Iterator<String>. For type safety also stringIterator() is provided.

    • Constructor Detail

      • CharArraySet

        public CharArraySet​(Version matchVersion,
                            int startSize,
                            boolean ignoreCase)
        Create set 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.
      • CharArraySet

        public CharArraySet​(Version matchVersion,
                            Collection<?> c,
                            boolean ignoreCase)
        Creates a set from a Collection of objects.
        Parameters:
        matchVersion - compatibility match version see Version note above for details.
        c - a collection whose elements to be placed into the set
        ignoreCase - false if and only if the set should be case sensitive otherwise true.
      • CharArraySet

        @Deprecated
        public CharArraySet​(int startSize,
                            boolean ignoreCase)
        Deprecated.
        Creates a set with enough capacity to hold startSize terms
        Parameters:
        startSize - the initial capacity
        ignoreCase - false if and only if the set should be case sensitive otherwise true.
      • CharArraySet

        @Deprecated
        public CharArraySet​(Collection<?> c,
                            boolean ignoreCase)
        Creates a set from a Collection of objects.
        Parameters:
        c - a collection whose elements to be placed into the set
        ignoreCase - false if and only if the set should be case sensitive otherwise true.