public static class CustomConcurrentHashMap.KeySet<K>
extends java.util.AbstractSet<K>
implements java.util.Set<K>, java.io.Serializable
Collections.newSetFromMap applied to a
CustomConcurrentHashMap, but possibly more
space-efficient. The set does not permit null elements. The
set is serializable; however, serializing a set that uses soft
or weak references can give unpredictable results.| Modifier and Type | Field and Description |
|---|---|
(package private) CustomConcurrentHashMap<K,K> |
cchm |
| Constructor and Description |
|---|
KeySet(CustomConcurrentHashMap.Strength strength,
CustomConcurrentHashMap.Equivalence<? super K> equivalence,
int expectedSize)
Creates a set with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(K e)
Adds the specified element to this set if there is not
already an element equivalent to the given element with
respect to this set's Equivalence.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
contains(java.lang.Object o)
Returns
true if this set contains an
element equivalent to the given element with respect
to this set's Equivalence. |
int |
hashCode()
Returns the sum of the hash codes of each element, as
computed by this set's Equivalence.
|
K |
intern(K e)
Returns an element equivalent to the given element with
respect to this set's Equivalence, if such an element
exists, else adds and returns the given element.
|
boolean |
isEmpty()
Returns
true if this set contains no elements. |
java.util.Iterator<K> |
iterator()
Returns a weakly consistent iterator over the
elements in this set, that may reflect some, all or none of
the changes made to the set after the iterator was created.
|
boolean |
remove(java.lang.Object o)
Removes an element equivalent to the given element with
respect to this set's Equivalence, if one is present.
|
int |
size()
Returns the number of elements in this set (its cardinality).
|
addAll, containsAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitfinal CustomConcurrentHashMap<K,K> cchm
public KeySet(CustomConcurrentHashMap.Strength strength, CustomConcurrentHashMap.Equivalence<? super K> equivalence, int expectedSize)
strength - the strength of elementsequivalence - the Equivalence to useexpectedSize - an estimate of the number of elements
that will be held in the set. If no estimate is known, zero
is an acceptable value.public K intern(K e)
e - the elementpublic boolean contains(java.lang.Object o)
true if this set contains an
element equivalent to the given element with respect
to this set's Equivalence.public java.util.Iterator<K> iterator()
public boolean add(K e)
public boolean remove(java.lang.Object o)
public boolean isEmpty()
true if this set contains no elements.public int size()
public void clear()
public int hashCode()