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.
| Method from org.apache.lucene.analysis.CharArraySet Detail: |
public boolean add(CharSequence text) {
return add(text.toString()); // could be more efficient
}
Add this CharSequence into the set |
public boolean add(String text) {
return add(text.toCharArray());
}
Add this String into the set |
public boolean add(char[] text) {
if (ignoreCase)
for(int i=0;i< text.length;i++)
text[i] = Character.toLowerCase(text[i]);
int slot = getSlot(text, 0, text.length);
if (entries[slot] != null) return false;
entries[slot] = text;
count++;
if (count + (count > >2) > entries.length) {
rehash();
}
return true;
}
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) {
if (o instanceof char[]) {
return add((char[])o);
} else if (o instanceof String) {
return add((String)o);
} else if (o instanceof CharSequence) {
return add((CharSequence)o);
} else {
return add(o.toString());
}
}
|
public boolean contains(CharSequence cs) {
return entries[getSlot(cs)] != null;
}
true if the CharSequence is in the set |
public boolean contains(Object o) {
if (o instanceof char[]) {
char[] text = (char[])o;
return contains(text, 0, text.length);
} else if (o instanceof CharSequence) {
return contains((CharSequence)o);
}
return false;
}
|
public boolean contains(char[] text,
int off,
int len) {
return entries[getSlot(text, off, len)] != null;
}
true if the len chars of text starting at off
are in the set |
public boolean isEmpty() {
return count==0;
}
|
public Iterator iterator() {
return new CharArraySetIterator();
}
|
public int size() {
return count;
}
|