public class CanonicalStringSet extends AbstractSet<String>
CanonicalStringSet.Canonicalizer.map(java.lang.Object)
.
Canonical string sets can be converted from and to string lists by using
addAll(String)
and toString()
.
A string list is a string which consists of zero or more elements
which are separated by the separator character provided to the
constructor.
Note that in general, a string list is just a sequence of strings elements.
In particular, a string list may be empty (but not null
) and
its elements don't have to be in canonical form, may be duplicated in the
list and may be listed in arbitrary order.
However, string lists have a canonical form, too:
A string list in canonical form (or canonical string list for short)
is a string list which contains only canonical strings in natural sort order
and does not contain any duplicates (so it's actually a set).
Unless otherwise documented, all Set
methods work on the
canonical form of the string elements in this set.
Null elements are not permitted in this set.
Modifier and Type | Class and Description |
---|---|
static interface |
CanonicalStringSet.Canonicalizer
An idempotent function which maps an arbitrary object to its canonical
string representation.
|
Constructor and Description |
---|
CanonicalStringSet(CanonicalStringSet.Canonicalizer canonicalizer,
char separator)
Constructs a new, empty set of canonical strings.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(String s) |
boolean |
addAll(CanonicalStringSet set)
Adds all canonical strings in the given set to this set after they have
been canonicalized by this set again.
|
boolean |
addAll(String list)
Adds the canonical form of all strings in the given list to this set.
|
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(CanonicalStringSet set)
Tests if all canonical strings in the given set are contained in this
set.
|
boolean |
containsAll(String list)
Tests if the canonical form of all strings in the given string list
is contained in this set.
|
boolean |
isEmpty() |
Iterator<String> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(CanonicalStringSet set)
Removes all canonical strings in the given set from this set.
|
boolean |
removeAll(String list)
Removes the canonical form of all strings in the given list from this set.
|
boolean |
retainAll(CanonicalStringSet set)
Retains all canonical strings in the given set in this set.
|
boolean |
retainAll(String list)
Retains the canonical form of all strings in the given list in this set.
|
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
String |
toString()
Returns the string list in canonical form for this canonical string set.
|
equals, hashCode, removeAll
addAll, containsAll, retainAll
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, retainAll, spliterator
parallelStream, removeIf, stream
public CanonicalStringSet(CanonicalStringSet.Canonicalizer canonicalizer, char separator)
canonicalizer
- the idempotent function to use for canonicalizing
strings.separator
- The separator character to use for string lists.public boolean add(String s)
The implementation in the class CanonicalStringSet
first
canonicalizes the given parameter before the operation is continued.
add
in interface Collection<String>
add
in interface Set<String>
add
in class AbstractCollection<String>
public boolean addAll(CanonicalStringSet set)
set
- a set of canonical strings.true
Iff this set of canonicalized strings has
changed as a result of the call.public boolean addAll(String list)
list
- a string list.true
Iff this set of canonicalized strings has
changed as a result of the call.public void clear()
clear
in interface Collection<String>
clear
in interface Set<String>
clear
in class AbstractCollection<String>
public boolean contains(Object o)
The implementation in the class CanonicalStringSet
first
canonicalizes the given parameter before the operation is continued.
contains
in interface Collection<String>
contains
in interface Set<String>
contains
in class AbstractCollection<String>
public boolean containsAll(CanonicalStringSet set)
set
- A set of canonical strings.true
Iff all strings in the given set are contained
in this set.public boolean containsAll(String list)
true
is returned.
In other words, an empty set is considered to be a true subset of this
set.list
- a string list.true
Iff the canonical form of all strings in the
given string list is contained in this set.public boolean isEmpty()
isEmpty
in interface Collection<String>
isEmpty
in interface Set<String>
isEmpty
in class AbstractCollection<String>
public boolean remove(Object o)
The implementation in the class CanonicalStringSet
first
canonicalizes the given parameter before the operation is continued.
remove
in interface Collection<String>
remove
in interface Set<String>
remove
in class AbstractCollection<String>
public boolean removeAll(CanonicalStringSet set)
set
- a set of strings.true
Iff this set changed as a result of the call.public boolean removeAll(String list)
list
- a string list.true
Iff this set changed as a result of the call.public boolean retainAll(CanonicalStringSet set)
set
- a set of canonical strings.true
Iff this set changed as a result of the call.public boolean retainAll(String list)
list
- a string list.true
Iff this set changed as a result of the call.public int size()
size
in interface Collection<String>
size
in interface Set<String>
size
in class AbstractCollection<String>
public Object[] toArray()
toArray
in interface Collection<String>
toArray
in interface Set<String>
toArray
in class AbstractCollection<String>
public <T> T[] toArray(T[] array)
toArray
in interface Collection<String>
toArray
in interface Set<String>
toArray
in class AbstractCollection<String>
public String toString()
toString
in class AbstractCollection<String>
Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.