K - the type of keysV - the type of values in the backing mapSerializable, Iterable<K>, Collection<K>, Set<K>
ConcurrentHashMap<K,V> public static final class ConcurrentHashMap.KeySetView<K,V> extends Object implements Set<K>, Serializable
Set of keys, in which additions may optionally be enabled by mapping to a common value. This class cannot be directly instantiated. See keySet(), keySet(V), newKeySet(), newKeySet(int).| Modifier and Type | Method | Description | 
|---|---|---|
| boolean | add | Adds the specified key to this set view by mapping the key to the default mapped value in the backing map, if defined. | 
| boolean | addAll | Adds all of the elements in the specified collection to this set, as if by calling  add(K)on each one. | 
| final void | clear() | Removes all of the elements from this view, by removing all the mappings from the map backing this view. | 
| boolean | contains | Returns  trueif this collection contains the specified element. | 
| final boolean | containsAll | Returns  trueif this collection contains all of the elements in the specified collection. | 
| boolean | equals | Indicates whether some other object is "equal to" this one. | 
| ConcurrentHashMap | getMap() | Returns the map backing this view. | 
| V | getMappedValue() | Returns the default mapped value for additions, or  nullif additions are not supported. | 
| int | hashCode() | Returns a hash code value for the object. | 
| final boolean | isEmpty() | Returns  trueif this collection contains no elements. | 
| Iterator | iterator() | Returns an iterator over the elements in this collection. | 
| boolean | remove | Removes the key from this map view, by removing the key (and its corresponding value) from the backing map. | 
| boolean | removeAll | Removes all of this collection's elements that are also contained in the specified collection (optional operation). | 
| final boolean | retainAll | Retains only the elements in this collection that are contained in the specified collection (optional operation). | 
| final int | size() | Returns the number of elements in this collection. | 
| final Object[] | toArray() | Returns an array containing all of the elements in this collection. | 
| final <T> T[] | toArray | Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. | 
| final String | toString() | Returns a string representation of this collection. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
parallelStream, removeIf, stream, toArray
clear, containsAll, isEmpty, removeAll, retainAll, size, spliterator, toArray, toArray
public V getMappedValue()
null if additions are not supported.null if not supportedpublic boolean contains(Object o)
true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that Objects.equals(o, e).contains in interface Collection<K>
contains in interface Set<K>
o - element whose presence in this collection is to be testedtrue if this collection contains the specified elementNullPointerException - if the specified key is nullpublic boolean remove(Object o)
remove in interface Collection<K>
remove in interface Set<K>
o - the key to be removed from the backing maptrue if the backing map contained the specified keyNullPointerException - if the specified key is nullpublic Iterator<K> iterator()
The returned iterator is weakly consistent.
public boolean add(K e)
add in interface Collection<K>
add in interface Set<K>
e - key to be addedtrue if this set changed as a result of the callNullPointerException - if the specified key is nullUnsupportedOperationException - if no default mapped value for additions was providedpublic boolean addAll(Collection<? extends K> c)
add(K) on each one.addAll in interface Collection<K>
addAll in interface Set<K>
c - the elements to be inserted into this settrue if this set changed as a result of the callNullPointerException - if the collection or any of its elements are null
UnsupportedOperationException - if no default mapped value for additions was providedpublic int hashCode()
ObjectHashMap.  The general contract of hashCode is: 
hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. equals method, then calling the 
     hashCode method on each of the two objects must produce the same integer result. equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables. public boolean equals(Object o)
Object The equals method implements an equivalence relation on non-null object references: 
x, x.equals(x) should return true. x and y, x.equals(y) should return true if and only if y.equals(x) returns true. x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified. x, x.equals(null) should return false. An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
public ConcurrentHashMap<K,V> getMap()
public final void clear()
clear in interface Collection<K>
public final int size()
CollectionInteger.MAX_VALUE elements, returns Integer.MAX_VALUE.size in interface Collection<K>
public final boolean isEmpty()
Collectiontrue if this collection contains no elements.isEmpty in interface Collection<K>
true if this collection contains no elementspublic final Object[] toArray()
CollectionObject. The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
toArray in interface Collection<K>
Object, containing all of the elements in this collectionpublic final <T> T[] toArray(T[] a)
CollectionIf this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.) 
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
toArray in interface Collection<K>
T - the component type of the array to contain the collectiona - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.public final String toString()
"[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).public final boolean containsAll(Collection<?> c)
Collectiontrue if this collection contains all of the elements in the specified collection.containsAll in interface Collection<K>
c - collection to be checked for containment in this collectiontrue if this collection contains all of the elements in the specified collectionpublic boolean removeAll(Collection<?> c)
CollectionremoveAll in interface Collection<K>
c - collection containing elements to be removed from this collectiontrue if this collection changed as a result of the callpublic final boolean retainAll(Collection<?> c)
CollectionretainAll in interface Collection<K>
c - collection containing elements to be retained in this collectiontrue if this collection changed as a result of the call
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/concurrent/ConcurrentHashMap.KeySetView.html