org.ehcache.internal.concurrent
Class ConcurrentHashMap.KeySetView<K,V>

java.lang.Object
  extended by org.ehcache.internal.concurrent.ConcurrentHashMap.KeySetView<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<K>, java.util.Collection<K>, java.util.Set<K>
Enclosing class:
ConcurrentHashMap<K,V>

public static class ConcurrentHashMap.KeySetView<K,V>
extends java.lang.Object
implements java.util.Set<K>, java.io.Serializable

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
 JSR166Helper.Spliterator<K> _spliterator()
           
 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(java.util.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.
 void clear()
          Removes all of the elements from this view, by removing all the mappings from the map backing this view.
 boolean contains(java.lang.Object o)
          
 boolean containsAll(java.util.Collection<?> c)
           
 boolean equals(java.lang.Object o)
           
 void forEach(JSR166Helper.Consumer<? super K> action)
           
 ConcurrentHashMap<K,V> getMap()
          Returns the map backing this view.
 V getMappedValue()
          Returns the default mapped value for additions, or null if additions are not supported.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Iterator<K> iterator()
          Returns an iterator over the elements in this collection.
 boolean remove(java.lang.Object o)
          Removes the key from this map view, by removing the key (and its corresponding value) from the backing map.
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 java.lang.String toString()
          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.Set
clear, containsAll, isEmpty, removeAll, retainAll, size, toArray, toArray
 

Method Detail

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(java.lang.Object o)

Specified by:
contains in interface java.util.Collection<K>
Specified by:
contains in interface java.util.Set<K>
Throws:
java.lang.NullPointerException - if the specified key is null

remove

public boolean remove(java.lang.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 java.util.Collection<K>
Specified by:
remove in interface java.util.Set<K>
Parameters:
o - the key to be removed from the backing map
Returns:
true if the backing map contained the specified key
Throws:
java.lang.NullPointerException - if the specified key is null

iterator

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

The returned iterator is weakly consistent.

Specified by:
iterator in interface java.lang.Iterable<K>
Specified by:
iterator in interface java.util.Collection<K>
Specified by:
iterator in interface java.util.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 java.util.Collection<K>
Specified by:
add in interface java.util.Set<K>
Parameters:
e - key to be added
Returns:
true if this set changed as a result of the call
Throws:
java.lang.NullPointerException - if the specified key is null
java.lang.UnsupportedOperationException - if no default mapped value for additions was provided

addAll

public boolean addAll(java.util.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 java.util.Collection<K>
Specified by:
addAll in interface java.util.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:
java.lang.NullPointerException - if the collection or any of its elements are null
java.lang.UnsupportedOperationException - if no default mapped value for additions was provided

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<K>
Specified by:
hashCode in interface java.util.Set<K>
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<K>
Specified by:
equals in interface java.util.Set<K>
Overrides:
equals in class java.lang.Object

_spliterator

public JSR166Helper.Spliterator<K> _spliterator()

forEach

public void forEach(JSR166Helper.Consumer<? super K> action)

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 java.util.Collection<E>

size

public final int size()
Specified by:
size in interface java.util.Collection<E>

isEmpty

public final boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>

toArray

public final java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>

toArray

public final <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E>

toString

public final java.lang.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 java.lang.Object
Returns:
a string representation of this collection

containsAll

public final boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E>

removeAll

public final boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E>

retainAll

public final boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E>