public class TrieSet extends AbstractSet<String>
String instances. In addition to providing
reduced space usage, testing for contains may offer increased performance
over a HashMap of String instances due to not requiring the
String.hashCode() to be computed.
This class is not synchronized. If concurrent updating behavior is required,
the map should be wrapped using Collections.synchronizedSet(Set). This map will never throw a
ConcurrentModificationException during iteration. The
behavior is unspecified if the map is modified while an iterator is being
used.
| Constructor and Description |
|---|
TrieSet()
Creates an empty set of strings.
|
TrieSet(Collection<String> c)
Creates a set of the strings contained in the collection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(String s)
Adds the specified element to this set if it is not already present.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
contains(Object o)
Returns
true if this set contains the specified element. |
boolean |
isEmpty()
Returns
true if this set contains no elements. |
Iterator<String> |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(Object o)
Removes the specified element from this set if it is present.
|
int |
size()
Returns the number of elements in this set.
|
String |
toString() |
equals, hashCode, removeAlladdAll, containsAll, retainAll, toArray, toArraypublic TrieSet()
public TrieSet(Collection<String> c)
public boolean add(String s)
add in interface Collection<String>add in interface Set<String>add in class AbstractCollection<String>public void clear()
clear in interface Collection<String>clear in interface Set<String>clear in class AbstractCollection<String>public boolean contains(Object o)
true if this set contains the specified element.contains in interface Collection<String>contains in interface Set<String>contains in class AbstractCollection<String>public boolean isEmpty()
true if this set contains no elements.isEmpty in interface Collection<String>isEmpty in interface Set<String>isEmpty in class AbstractCollection<String>public boolean remove(Object o)
remove in interface Collection<String>remove in interface Set<String>remove in class AbstractCollection<String>public int size()
size in interface Collection<String>size in interface Set<String>size in class AbstractCollection<String>public String toString()
toString in class AbstractCollection<String>Copyright © 2012. All Rights Reserved.