Save This Page
Home » lucene-3.0.1-src » org.apache » lucene » analysis » [javadoc | source]
public class: CharArraySet [javadoc | source]

All Implemented Interfaces:
    Set, Collection

Direct Known Subclasses:

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.

Please note: This class implements Set but does not behave like it should in all cases. The generic type is {@code Set}, 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 {@code char[]} buffer. The same behaviour have the {@code contains()} methods. The #iterator() returns an {@code Iterator}. For type safety also #stringIterator() is provided.
Nested Class Summary:
public class  CharArraySet.CharArraySetIterator  The Iterator for this set. Strings are constructed on the fly, so use nextCharArray for more efficient access. 
Field Summary
public static final  CharArraySet EMPTY_SET     
 public CharArraySet(int startSize,
    boolean ignoreCase) 
 public CharArraySet(Collection<Object> c,
    boolean ignoreCase) 
    Create set from a Collection of char[] or String
Method from org.apache.lucene.analysis.CharArraySet Summary:
add,   add,   add,   add,   contains,   contains,   contains,   copy,   isEmpty,   iterator,   size,   stringIterator,   unmodifiableSet
Methods from java.util.AbstractSet:
equals,   hashCode,   removeAll
Methods from java.util.AbstractCollection:
add,   addAll,   clear,   contains,   containsAll,   isEmpty,   iterator,   remove,   removeAll,   retainAll,   size,   toArray,   toArray,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.analysis.CharArraySet Detail:
 public boolean add(CharSequence text) 
    Add this CharSequence into the set
 public boolean add(String text) 
    Add this String into the set
 public boolean add(char[] text) 
    Add this char[] directly to the set. 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.
 public boolean add(Object o) 
 public boolean contains(CharSequence cs) 
    true if the CharSequence is in the set
 public boolean contains(Object o) 
 public boolean contains(char[] text,
    int off,
    int len) 
    true if the len chars of text starting at off are in the set
 public static CharArraySet copy(Set<?> set) 
    Returns a copy of the given set as a CharArraySet . If the given set is a CharArraySet the ignoreCase property will be preserved.
 public boolean isEmpty() 
 public Iterator<Object> iterator() 
    returns an iterator of new allocated Strings, this method violates the Set interface
 public int size() 
 public Iterator<String> stringIterator() 
    returns an iterator of new allocated Strings
 public static CharArraySet unmodifiableSet(CharArraySet set) 
    Returns an unmodifiable CharArraySet . This allows to provide unmodifiable views of internal sets for "read-only" use.