public class CaseInsensitiveStringSet extends java.lang.Object implements java.util.Set<java.lang.String>
Set of Strings, which allows
storing strings in a case-insensitive manner. Two strings which only differ
in case are handled as equal and can thus occur just once in the set (the
first string added to the set is retained).
It also allows accessing the case-sensitive representation of a string that
was stored utilizing the get(String) method. I.e. storing string "A"
in the set and calling set.get("a") will return the original representation
"A".
This class does not inherit from AbstractSet or
AbstractCollection as most provided operations have higher
performance directly using the hash map instead of the iterator
implementations. Moreover, comparison in AbstractCollection is
performed with equals and the CaseInsensitiveStringSet violates this
contract as it requires comparison after normalization with
getMappingKey(String).
| Constructor and Description |
|---|
CaseInsensitiveStringSet()
Constructor.
|
CaseInsensitiveStringSet(java.util.Collection<java.lang.String> strings)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.String e) |
boolean |
addAll(java.util.Collection<? extends java.lang.String> c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
java.lang.String |
get(java.lang.String string)
Returns the case-sensitive representation of the given string, as it was
stored with the call to
add(String) or null if the
string is not stored in the Set. |
boolean |
isEmpty() |
java.util.Iterator<java.lang.String> |
iterator() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString() |
public CaseInsensitiveStringSet()
public CaseInsensitiveStringSet(java.util.Collection<java.lang.String> strings)
public java.lang.String get(java.lang.String string)
add(String) or null if the
string is not stored in the Set.public int size()
size in interface java.util.Collection<java.lang.String>size in interface java.util.Set<java.lang.String>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.String>isEmpty in interface java.util.Set<java.lang.String>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<java.lang.String>contains in interface java.util.Set<java.lang.String>public java.util.Iterator<java.lang.String> iterator()
iterator in interface java.lang.Iterable<java.lang.String>iterator in interface java.util.Collection<java.lang.String>iterator in interface java.util.Set<java.lang.String>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.String>toArray in interface java.util.Set<java.lang.String>public <T> T[] toArray(T[] a)
toArray in interface java.util.Collection<java.lang.String>toArray in interface java.util.Set<java.lang.String>public boolean add(java.lang.String e)
add in interface java.util.Collection<java.lang.String>add in interface java.util.Set<java.lang.String>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<java.lang.String>remove in interface java.util.Set<java.lang.String>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<java.lang.String>containsAll in interface java.util.Set<java.lang.String>public boolean addAll(java.util.Collection<? extends java.lang.String> c)
addAll in interface java.util.Collection<java.lang.String>addAll in interface java.util.Set<java.lang.String>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<java.lang.String>retainAll in interface java.util.Set<java.lang.String>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<java.lang.String>removeAll in interface java.util.Set<java.lang.String>public void clear()
clear in interface java.util.Collection<java.lang.String>clear in interface java.util.Set<java.lang.String>public java.lang.String toString()
toString in class java.lang.Object