public class

CharArraySet

extends AbstractSet<E>
java.lang.Object
   ↳ java.util.AbstractCollection<E>
     ↳ java.util.AbstractSet<E>
       ↳ org.apache.lucene.analysis.CharArraySet

Class Overview

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 Set<Object>, because you can add any object to it, that has a string representation. The add methods will use toString() and store the result using a char[] buffer. The same behaviour have the contains() methods. The iterator() returns an Iterator<String>. For type safety also stringIterator() is provided.

Summary

Nested Classes
class CharArraySet.CharArraySetIterator The Iterator for this set. 
Fields
public static final CharArraySet EMPTY_SET
Public Constructors
CharArraySet(int startSize, boolean ignoreCase)
Create set with enough capacity to hold startSize terms
CharArraySet(Collection<? extends Object> c, boolean ignoreCase)
Create set from a Collection of char[] or String
Public Methods
boolean add(CharSequence text)
Add this CharSequence into the set
boolean add(char[] text)
Add this char[] directly to the set.
boolean add(Object o)
boolean add(String text)
Add this String into the set
boolean contains(char[] text, int off, int len)
true if the len chars of text starting at off are in the set
boolean contains(Object o)
boolean contains(CharSequence cs)
true if the CharSequence is in the set
static CharArraySet copy(Set<?> set)
Returns a copy of the given set as a CharArraySet.
boolean isEmpty()
Iterator<Object> iterator()
returns an iterator of new allocated Strings, this method violates the Set interface
int size()
Iterator<String> stringIterator()
returns an iterator of new allocated Strings
static CharArraySet unmodifiableSet(CharArraySet set)
Returns an unmodifiable CharArraySet.
[Expand]
Inherited Methods
From class java.util.AbstractSet
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface java.util.Set

Fields

public static final CharArraySet EMPTY_SET

Public Constructors

public CharArraySet (int startSize, boolean ignoreCase)

Create set with enough capacity to hold startSize terms

public CharArraySet (Collection<? extends Object> c, boolean ignoreCase)

Create set from a Collection of char[] or String

Public Methods

public boolean add (CharSequence text)

Add this CharSequence 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 add (String text)

Add this String into the set

public boolean contains (char[] text, int off, int len)

true if the len chars of text starting at off are in the set

public boolean contains (Object o)

public boolean contains (CharSequence cs)

true if the CharSequence is 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.

Parameters
set a set to copy
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.

Parameters
set a set for which the unmodifiable set is returned.
Returns
Throws
NullPointerException if the given set is null.