public class CharArraySet
extends java.util.AbstractSet<java.lang.Object>
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<char[]>
.
Modifier and Type | Field and Description |
---|---|
static CharArraySet |
EMPTY_SET
An empty
CharArraySet . |
private CharArrayMap<java.lang.Object> |
map |
private static java.lang.Object |
PLACEHOLDER |
Constructor and Description |
---|
CharArraySet(CharArrayMap<java.lang.Object> map)
Create set from the specified map (internal only), used also by
CharArrayMap.keySet() |
CharArraySet(java.util.Collection<?> c,
boolean ignoreCase)
Creates a set from a Collection of objects.
|
CharArraySet(int startSize,
boolean ignoreCase)
Create set with enough capacity to hold startSize terms
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(char[] text)
Add this char[] directly to the set.
|
boolean |
add(java.lang.CharSequence text)
Add this CharSequence into the set
|
boolean |
add(java.lang.Object o) |
boolean |
add(java.lang.String text)
Add this String into the set
|
void |
clear()
Clears all entries in this 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(java.lang.CharSequence cs)
true if the
CharSequence is in the set |
boolean |
contains(java.lang.Object o) |
static CharArraySet |
copy(java.util.Set<?> set)
Returns a copy of the given set as a
CharArraySet . |
java.util.Iterator<java.lang.Object> |
iterator()
Returns an
Iterator for char[] instances in this set. |
int |
size() |
java.lang.String |
toString() |
static CharArraySet |
unmodifiableSet(CharArraySet set)
Returns an unmodifiable
CharArraySet . |
addAll, containsAll, isEmpty, remove, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public static final CharArraySet EMPTY_SET
CharArraySet
.private static final java.lang.Object PLACEHOLDER
private final CharArrayMap<java.lang.Object> map
public CharArraySet(int startSize, boolean ignoreCase)
startSize
- the initial capacityignoreCase
- false
if and only if the set should be case sensitive
otherwise true
.public CharArraySet(java.util.Collection<?> c, boolean ignoreCase)
c
- a collection whose elements to be placed into the setignoreCase
- false
if and only if the set should be case sensitive
otherwise true
.CharArraySet(CharArrayMap<java.lang.Object> map)
CharArrayMap.keySet()
public void clear()
Set.remove(java.lang.Object)
.clear
in interface java.util.Collection<java.lang.Object>
clear
in interface java.util.Set<java.lang.Object>
clear
in class java.util.AbstractCollection<java.lang.Object>
public boolean contains(char[] text, int off, int len)
len
chars of text
starting at off
are in the setpublic boolean contains(java.lang.CharSequence cs)
CharSequence
is in the setpublic boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<java.lang.Object>
contains
in interface java.util.Set<java.lang.Object>
contains
in class java.util.AbstractCollection<java.lang.Object>
public boolean add(java.lang.Object o)
add
in interface java.util.Collection<java.lang.Object>
add
in interface java.util.Set<java.lang.Object>
add
in class java.util.AbstractCollection<java.lang.Object>
public boolean add(java.lang.CharSequence text)
public boolean add(java.lang.String text)
public boolean add(char[] text)
public int size()
size
in interface java.util.Collection<java.lang.Object>
size
in interface java.util.Set<java.lang.Object>
size
in class java.util.AbstractCollection<java.lang.Object>
public static CharArraySet unmodifiableSet(CharArraySet set)
CharArraySet
. This allows to provide
unmodifiable views of internal sets for "read-only" use.set
- a set for which the unmodifiable set is returned.CharArraySet
.java.lang.NullPointerException
- if the given set is null
.public static CharArraySet copy(java.util.Set<?> set)
CharArraySet
. If the given set
is a CharArraySet
the ignoreCase property will be preserved.set
- a set to copyCharArraySet
. If the given set
is a CharArraySet
the ignoreCase property as well as the
matchVersion will be of the given set will be preserved.public java.util.Iterator<java.lang.Object> iterator()
Iterator
for char[]
instances in this set.iterator
in interface java.lang.Iterable<java.lang.Object>
iterator
in interface java.util.Collection<java.lang.Object>
iterator
in interface java.util.Set<java.lang.Object>
iterator
in class java.util.AbstractCollection<java.lang.Object>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<java.lang.Object>