public class CharArraySet extends AbstractSet<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 . |
Constructor and Description |
---|
CharArraySet(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(CharSequence text)
Add this CharSequence into the set
|
boolean |
add(Object o) |
boolean |
add(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(CharSequence cs)
true if the
CharSequence is in the set |
boolean |
contains(Object o) |
static CharArraySet |
copy(Set<?> set)
Returns a copy of the given set as a
CharArraySet . |
Iterator<Object> |
iterator()
Returns an
Iterator for char[] instances in this set. |
int |
size() |
String |
toString() |
static CharArraySet |
unmodifiableSet(CharArraySet set)
Returns an unmodifiable
CharArraySet . |
equals, hashCode, removeAll
addAll, containsAll, isEmpty, remove, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public static final CharArraySet EMPTY_SET
CharArraySet
.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(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
.public void clear()
Set.remove(java.lang.Object)
.clear
in interface Collection<Object>
clear
in interface Set<Object>
clear
in class AbstractCollection<Object>
public boolean contains(char[] text, int off, int len)
len
chars of text
starting at off
are in the setpublic boolean contains(CharSequence cs)
CharSequence
is in the setpublic boolean contains(Object o)
contains
in interface Collection<Object>
contains
in interface Set<Object>
contains
in class AbstractCollection<Object>
public boolean add(Object o)
add
in interface Collection<Object>
add
in interface Set<Object>
add
in class AbstractCollection<Object>
public boolean add(CharSequence text)
public boolean add(String text)
public boolean add(char[] text)
public int size()
size
in interface Collection<Object>
size
in interface Set<Object>
size
in class AbstractCollection<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
.NullPointerException
- if the given set is null
.public static CharArraySet copy(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 String toString()
toString
in class AbstractCollection<Object>
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.