Set that is a view on the keys of a Map that have a certain value.
The value is controlled by the concrete subclass (getValue()). It can, for example, be a
boolean or a counter, depending on the use case. If the value is equal to a "removed" sentinel
value.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final V | |
| private final MapValueSet. |
| Access | Constructor and Description |
|---|---|
| pack-priv | MapValueSet(Map<? extends T, V> map, MapValueSet.
|
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(T
element to be added to this set e)Implements java. Adds an entry to the set, adding it to the backing map if necessary. |
| public boolean | addAll(Collection<? extends T>
collection containing elements to be added to this set c)Implements java. Adds all of the elements in the specified collection to this set if they're not already present (optional operation). |
| public void | clear()
Implements java. Marks all entries in the backing map that are currently considered contained in this set as
removed; see |
| public boolean | contains(Object
element whose presence in this set is to be tested o)Implements java. Returns |
| public boolean | containsAll(Collection<?>
collection to be checked for containment in this set c)Implements java. Returns |
| private @NonNull V | |
| private boolean | |
| public boolean | |
| public Iterator | |
| public void | markAllRemoved()
Sets all entries in the backing map to the "removed" sentinel, or removes them all if that
value is |
| public void | markRemoved(T
The element to remove. elem)Marks the given element as "removed"; this may actually add an element to the underlying map. |
| public boolean | remove(Object
object to be removed from this set, if present o)Implements java. Removes the specified element from this set if it is present (optional operation). |
| public boolean | removeAll(Collection<?>
collection containing elements to be removed from this set c)Implements java. Removes from this set all of its elements that are contained in the specified collection (optional operation). |
| public boolean | retainAll(Collection<?>
collection containing elements to be retained in this set c)Implements java. Retains only the elements in this set that are contained in the specified collection (optional operation). |
| public int | |
| public Object[] | toArray()
Implements java. Returns an array containing all of the elements in this set. |
| public <E> E[] | toArray(E[]
the array into which the elements of this set are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose. a)Implements java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. |
| public boolean | update(T
The entry to update. e)Updates an already-existing entry in the backing map to the current value (obtained via
|
| map | back to summary |
|---|---|
| private final Map<T, V> map | |
| removedSentinel | back to summary |
|---|---|
| private final V removedSentinel | |
| valueSupplier | back to summary |
|---|---|
| private final MapValueSet. | |
| MapValueSet | back to summary |
|---|---|
pack-priv MapValueSet(Map<? extends T, V> map, MapValueSet.
| |
| add | back to summary |
|---|---|
| public boolean add(T e) Implements java. Adds an entry to the set, adding it to the backing map if necessary.
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(Collection<? extends T> c) Implements java. Doc from java. Adds all of the elements in the specified collection to this set if
they're not already present (optional operation). If the specified
collection is also a set, the
| |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Marks all entries in the backing map that are currently considered contained in this set as
removed; see
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object o) Implements java. Doc from java. Returns | |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(Collection<?> c) Implements java. Doc from java. Returns
| |
| getValue | back to summary |
|---|---|
| private @NonNull V getValue() | |
| isDefinitelyEmpty | back to summary |
|---|---|
| private boolean isDefinitelyEmpty() | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee). | |
| markAllRemoved | back to summary |
|---|---|
| public void markAllRemoved() Sets all entries in the backing map to the "removed" sentinel, or removes them all if that
value is | |
| markRemoved | back to summary |
|---|---|
| public void markRemoved(T elem) Marks the given element as "removed"; this may actually add an element to the underlying map. Depending on the "removed" sentinel, the key may be added (if value is non-null but the map does not yet contain the key), modified (value is non-null, and the map has a different value for the key), or removed (if value is null).
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object o) Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> c) Implements java. Doc from java. Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> c) Implements java. Doc from java. Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
| |
| size | back to summary |
|---|---|
| public int size() Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Implements java. Doc from java. Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs.
| |
| toArray | back to summary |
|---|---|
| public <E> E[] toArray(E[] a) Implements java. Doc from java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set. If this set fits in the specified array with room to spare
(i.e., the array has more elements than this set), the element in
the array immediately following the end of the set is set to
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. Like the Suppose
String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to
toArray().
| |
| update | back to summary |
|---|---|
| public boolean update(T e) Updates an already-existing entry in the backing map to the current value (obtained via
| |
| Modifier and Type | Method and Description |
|---|---|
| public V |
| supplyValue | back to summary |
|---|---|
| public V supplyValue() | |