Class 
Use 
SUMMARY: NESTED | FIELD | CONSTR | METHOD      DETAIL: FIELD | CONSTR | METHOD
FlexDoc/Javadoc 2.0
Demo Java Doc

java.base / java.util.concurrent
Class ConcurrentHashMap.KeySetView<K,V>
java.lang.Object
  java.util.concurrent.ConcurrentHashMap.KeySetView<K,V>
All Implemented Interfaces:
Serializable, Iterable<K>, Collection<K>, Set<K>
Enclosing class:
ConcurrentHashMap<K,V>

public static class ConcurrentHashMap.KeySetView<K,V>
extends Object
implements Set<K>, Serializable, Collection<K>
A view of a ConcurrentHashMap as a 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).
Since:
1.8
See Also:
Serialized Form

Method Summary
boolean
add(K e)
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(Collection<? extends K> c)
Adds all of the elements in the specified collection to this set, as if by calling add(K) on each one.
final void
Removes all of the elements from this view, by removing all the mappings from the map backing this view.
boolean
Returns true if this collection contains the specified element.
final boolean
Returns true if this collection contains all of the elements in the specified collection.
boolean
Indicates whether some other object is "equal to" this one.
void
forEach(Consumer<? super K> action)
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
Returns the map backing this view.
Returns the default mapped value for additions, or null if additions are not supported.
int
Returns a hash code value for the object.
final boolean
Returns true if this collection contains no elements.
Returns an iterator over the elements in this collection.
boolean
Removes the key from this map view, by removing the key (and its corresponding value) from the backing map.
boolean
Removes all of this collection's elements that are also contained in the specified collection (optional operation).
final boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation).
final int
Returns the number of elements in this collection.
Creates a Spliterator over the elements in this collection.
final Object[]
Returns an array containing all of the elements in this collection.
final <TT[]
toArray(T[] a)
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
Returns a string representation of this collection.
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
copyOf, of, of, of, of, of, of, of, of, of, of, of, of
Method Detail
getMap
public ConcurrentHashMap<K,V> getMap
()
Returns the map backing this view.
Returns:
the map backing this view

clear
public final void clear
()
Removes all of the elements from this view, by removing all the mappings from the map backing this view.
Specified by:
clear in interface Collection<K>
clear in interface Set<K>

size
public final int size
()
Description copied from interface: Collection
Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
Specified by:
size in interface Collection<K>
size in interface Set<K>
Returns:
the number of elements in this collection

isEmpty
public final boolean isEmpty
()
Description copied from interface: Collection
Returns true if this collection contains no elements.
Specified by:
isEmpty in interface Collection<K>
isEmpty in interface Set<K>
Returns:
true if this collection contains no elements

toArray
public final Object[] toArray
()
Description copied from interface: Collection
Returns an array containing all of the elements in this collection. 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. The returned array's runtime component type is Object.

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.

Specified by:
toArray in interface Collection<K>
toArray in interface Set<K>
Returns:
an array, whose runtime component type is Object, containing all of the elements in this collection

toArray
public final <T> T[] toArray
(T[] a)
Description copied from interface: Collection
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection 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 collection.

If 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.

Specified by:
toArray in interface Collection<K>
toArray in interface Set<K>
Type Parameters:
T - the component type of the array to contain the collection
Parameters:
a - 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.
Returns:
an array containing all of the elements in this collection

toString
public final String toString
()
Returns a string representation of this collection. The string representation consists of the string representations of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).
Overrides:
toString in class Object
Returns:
a string representation of this collection

containsAll
public final boolean containsAll
(Collection<?> c)
Description copied from interface: Collection
Returns true if this collection contains all of the elements in the specified collection.
Specified by:
containsAll in interface Collection<K>
containsAll in interface Set<K>
Parameters:
c - collection to be checked for containment in this collection
Returns:
true if this collection contains all of the elements in the specified collection
See Also:
Collection.contains(Object)

removeAll
public boolean removeAll
(Collection<?> c)
Description copied from interface: Collection
Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
Specified by:
removeAll in interface Collection<K>
removeAll in interface Set<K>
Parameters:
c - collection containing elements to be removed from this collection
Returns:
true if this collection changed as a result of the call
See Also:
Collection.remove(Object), Collection.contains(Object)

retainAll
public final boolean retainAll
(Collection<?> c)
Description copied from interface: Collection
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
Specified by:
retainAll in interface Collection<K>
retainAll in interface Set<K>
Parameters:
c - collection containing elements to be retained in this collection
Returns:
true if this collection changed as a result of the call
See Also:
Collection.remove(Object), Collection.contains(Object)

getMappedValue
public V getMappedValue
()
Returns the default mapped value for additions, or null if additions are not supported.
Returns:
the default mapped value for additions, or null if not supported

contains
public boolean contains
(Object o)
Returns 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).
Specified by:
contains in interface Collection<K>
contains in interface Set<K>
Parameters:
o - element whose presence in this collection is to be tested
Returns:
true if this collection contains the specified element
Throws:
NullPointerException - if the specified key is null

remove
public boolean remove
(Object o)
Removes the key from this map view, by removing the key (and its corresponding value) from the backing map. This method does nothing if the key is not in the map.
Specified by:
remove in interface Collection<K>
remove in interface Set<K>
Parameters:
o - the key to be removed from the backing map
Returns:
true if the backing map contained the specified key
Throws:
NullPointerException - if the specified key is null

iterator
public Iterator<K> iterator
()
Returns an iterator over the elements in this collection.

The returned iterator is weakly consistent.

Specified by:
iterator in interface Collection<K>
iterator in interface Iterable<K>
iterator in interface Set<K>
Returns:
an iterator over the keys of the backing map

add
public boolean add
(K e)
Adds the specified key to this set view by mapping the key to the default mapped value in the backing map, if defined.
Specified by:
add in interface Collection<K>
add in interface Set<K>
Parameters:
e - key to be added
Returns:
true if this set changed as a result of the call
Throws:
NullPointerException - if the specified key is null
UnsupportedOperationException - if no default mapped value for additions was provided

addAll
public boolean addAll
(Collection<? extends K> c)
Adds all of the elements in the specified collection to this set, as if by calling add(K) on each one.
Specified by:
addAll in interface Collection<K>
addAll in interface Set<K>
Parameters:
c - the elements to be inserted into this set
Returns:
true if this set changed as a result of the call
Throws:
NullPointerException - if the collection or any of its elements are null
UnsupportedOperationException - if no default mapped value for additions was provided
See Also:
Collection.add(Object)

hashCode
public int hashCode
()
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

Specified by:
hashCode in interface Collection<K>
hashCode in interface Set<K>
Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), System.identityHashCode(Object)

equals
public boolean equals
(Object o)
Description copied from class: Object
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

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.

Specified by:
equals in interface Collection<K>
equals in interface Set<K>
Overrides:
equals in class Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode(), HashMap

spliterator
public Spliterator<K> spliterator
()
Description copied from interface: Collection
Creates a Spliterator over the elements in this collection. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports Spliterator.SIZED and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the Collection.stream() and Collection.parallelStream() methods, spliterators should either have the characteristic of IMMUTABLE or CONCURRENT, or be late-binding. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the Collection.stream() and Collection.parallelStream() methods to create streams using a Supplier of the spliterator, as in:


     Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)
 

These requirements ensure that streams produced by the Collection.stream() and Collection.parallelStream() methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Specified by:
spliterator in interface Collection<K>
spliterator in interface Iterable<K>
spliterator in interface Set<K>
Returns:
a Spliterator over the elements in this collection

forEach
public void forEach
(Consumer<? super K> action)
Description copied from interface: Iterable
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.

Specified by:
forEach in interface Iterable<K>
Parameters:
action - The action to be performed for each element

 Class 
Use 
SUMMARY: NESTED | FIELD | CONSTR | METHOD      DETAIL: FIELD | CONSTR | METHOD
FlexDoc/Javadoc 2.0
Demo Java Doc

Java API documentation generated with FlexDoc/Javadoc 2.0 using JavadocClassic 3.0 template set.
FlexDoc/Javadoc is a template-driven programming tool for rapid development of any Javadoc-based Java API documentation generators (i.e. doclets). If you need to customize your Javadoc without writing a full-blown doclet from scratch, FlexDoc/Javadoc may be the only tool able to help you! Find out more at www.flexdoc.xyz