Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public static class ConcurrentHashMap.KeySetView<K, V>
- Object
- AbstractCollection<K>
- AbstractSet<K>
- ConcurrentHashMap.KeySetView
ImplementsCollection<K>, Iterable<K>, Serializable, Set<K>
java.util.concurrent.ConcurrentHashMap.KeySetView: the keys of a
map as a set. A view created with a mapped value (keySet(V),
newKeySet()) also accepts add, which maps the key to that value.Methods
public ConcurrentHashMap<K, V> getMap() | The map this is a view of. |
public V getMappedValue() | |
public Iterator<K> iterator() | Returns an instance of Iterator that may be used to access the objects contained by this Collection. |
public int size() | Returns a count of how many objects this Collection contains. |
public boolean isEmpty() | Returns if this Collection contains no elements. |
public boolean contains(Object o) | Tests whether this Collection contains the specified object. |
public boolean remove(Object o) | Removes one instance of the specified object from this Collection if one is contained (optional). |
public void clear() | Removes all elements from this Collection, leaving it empty (optional). |
public boolean add(K e) | Attempts to add object to the contents of this Collection (optional). |
public boolean addAll(Collection<? extends K> c) | Attempts to add all of the objects contained in collection to the contents of this Collection (optional). |
Inherited methods
From AbstractSet
Method details
getMap
public ConcurrentHashMap<K, V> getMap()getMappedValue
public V getMappedValue()iterator
public Iterator<K> iterator()Returns an instance of Iterator that may be used to access the
objects contained by this Collection. The order in which the elements are
returned by the Iterator is not defined unless the instance of the
Collection has a defined order. In that case, the elements are returned in that order.
In this class this method is declared abstract and has to be implemented
by concrete Collection implementations.
Returns
Collection contents.size
public int size()Returns a count of how many objects this Collection contains.
In this class this method is declared abstract and has to be implemented
by concrete Collection implementations.
Returns
Collection contains, or Integer.MAX_VALUE
if there are more than Integer.MAX_VALUE elements in this
Collection.isEmpty
public boolean isEmpty()Collection contains no elements. This implementation
tests, whether size returns 0.Returns
true if this Collection has no elements, false
otherwise.See also
contains
public boolean contains(Object o)Collection contains the specified object. This
implementation iterates over this Collection and tests, whether any
element is equal to the given object. If object != null then
object.equals(e) is called for each element e returned by
the iterator until the element is found. If object == null then
each element e returned by the iterator is compared with the test
e == null.Parameters
oObject- the object to search for.
Returns
true if object is an element of this Collection, false otherwise.Throws
ClassCastException- if the object to look for isn’t of the correct type.
NullPointerException- if the object to look for is
nulland thisCollectiondoesn’t supportnullelements.
remove
public boolean remove(Object o)Collection if one
is contained (optional). This implementation iterates over this
Collection and tests for each element e returned by the iterator,
whether e is equal to the given object. If object != null
then this test is performed using object.equals(e), otherwise
using object == null. If an element equal to the given object is
found, then the remove method is called on the iterator and
true is returned, false otherwise. If the iterator does
not support removing elements, an UnsupportedOperationException
is thrown.Parameters
oObject- the object to remove.
Returns
true if this Collection is modified, false
otherwise.Throws
UnsupportedOperationException- if removing from this
Collectionis not supported. ClassCastException- if the object passed is not of the correct type.
NullPointerException- if
objectisnulland thisCollectiondoesn’t supportnullelements.
clear
public void clear()Removes all elements from this Collection, leaving it empty (optional).
This implementation iterates over this Collection and calls the remove method on each element. If the iterator does not support removal
of elements, an UnsupportedOperationException is thrown.
Concrete implementations usually can clear a Collection more efficiently
and should therefore overwrite this method.
Throws
UnsupportedOperationException- it the iterator does not support removing elements from
this
Collection
add
public boolean add(K e)Attempts to add object to the contents of this
Collection (optional).
After this method finishes successfully it is guaranteed that the object is contained in the collection.
If the collection was modified it returns true, false if
no changes were made.
An implementation of Collection may narrow the set of accepted
objects, but it has to specify this in the documentation. If the object
to be added does not meet this restriction, then an
IllegalArgumentException is thrown.
If a collection does not yet contain an object that is to be added and adding the object fails, this method must throw an appropriate unchecked Exception. Returning false is not permitted in this case because it would violate the postcondition that the element will be part of the collection after this method finishes.
Parameters
eK- the object to add.
Returns
true if this Collection is
modified, false otherwise.Throws
UnsupportedOperationException- if adding to this
Collectionis not supported. ClassCastException- if the class of the object is inappropriate for this collection.
IllegalArgumentException- if the object cannot be added to this
Collection. NullPointerException- if null elements cannot be added to the
Collection.
addAll
public boolean addAll(Collection<? extends K> c)Attempts to add all of the objects contained in collection
to the contents of this Collection (optional). This implementation
iterates over the given Collection and calls add for each
element. If any of these calls return true, then true is
returned as result of this method call, false otherwise. If this
Collection does not support adding elements, an UnsupportedOperationException is thrown.
If the passed Collection is changed during the process of adding elements
to this Collection, the behavior depends on the behavior of the passed
Collection.
Parameters
cCollection<? extends K>- the collection of objects.
Returns
true if this Collection is modified, false
otherwise.Throws
UnsupportedOperationException- if adding to this
Collectionis not supported. ClassCastException- if the class of an object is inappropriate for this
Collection. IllegalArgumentException- if an object cannot be added to this
Collection. NullPointerException- if
collectionisnull, or if it containsnullelements and thisCollectiondoes not support such elements.