org.codehaus.gpars

groovyx.gpars.extra166y
[Java] Class CustomConcurrentHashMap.KeySet

java.lang.Object
  java.util.AbstractCollection
      java.util.AbstractSet
          groovyx.gpars.extra166y.CustomConcurrentHashMap.KeySet
All Implemented Interfaces:
java.util.Set, java.io.Serializable

public static class CustomConcurrentHashMap.KeySet
extends java.util.AbstractSet

A hash-based set with properties identical to those of Collections.newSetFromMap applied to a CustomConcurrentHashMap, but possibly more space-efficient. The set does not permit null elements. The set is serializable; however, serializing a set that uses soft or weak references can give unpredictable results.


Field Summary
CustomConcurrentHashMap cchm

 
Constructor Summary
CustomConcurrentHashMap.KeySet(Strength strength, Equivalence equivalence, int expectedSize)

Creates a set with the given parameters

 
Method Summary
boolean add(java.lang.Object e)

Adds the specified element to this set if there is not already an element equivalent to the given element with respect to this set's Equivalence.

void clear()

Removes all of the elements from this set.

boolean contains(java.lang.Object o)

Returns true if this set contains an element equivalent to the given element with respect to this set's Equivalence.

int hashCode()

Returns the sum of the hash codes of each element, as computed by this set's Equivalence.

java.lang.Object intern(java.lang.Object e)

Returns an element equivalent to the given element with respect to this set's Equivalence, if such an element exists, else adds and returns the given element.

boolean isEmpty()

Returns true if this set contains no elements.

java.util.Iterator iterator()

Returns a weakly consistent iterator over the elements in this set, that may reflect some, all or none of the changes made to the set after the iterator was created.

boolean remove(java.lang.Object o)

Removes an element equivalent to the given element with respect to this set's Equivalence, if one is present.

int size()

Returns the number of elements in this set (its cardinality).

 
Methods inherited from class java.util.AbstractSet
java.util.AbstractSet#equals(java.lang.Object), java.util.AbstractSet#hashCode(), java.util.AbstractSet#removeAll(java.util.Collection), java.util.AbstractSet#add(java.lang.Object), java.util.AbstractSet#toString(), java.util.AbstractSet#clear(), java.util.AbstractSet#contains(java.lang.Object), java.util.AbstractSet#isEmpty(), java.util.AbstractSet#addAll(java.util.Collection), java.util.AbstractSet#iterator(), java.util.AbstractSet#size(), java.util.AbstractSet#toArray(), java.util.AbstractSet#toArray([Ljava.lang.Object;), java.util.AbstractSet#remove(java.lang.Object), java.util.AbstractSet#containsAll(java.util.Collection), java.util.AbstractSet#retainAll(java.util.Collection), java.util.AbstractSet#wait(long), java.util.AbstractSet#wait(), java.util.AbstractSet#wait(long, int), java.util.AbstractSet#getClass(), java.util.AbstractSet#notify(), java.util.AbstractSet#notifyAll(), java.util.AbstractSet#iterator(), java.util.AbstractSet#size()
 
Methods inherited from class java.util.AbstractCollection
java.util.AbstractCollection#add(java.lang.Object), java.util.AbstractCollection#toString(), java.util.AbstractCollection#clear(), java.util.AbstractCollection#contains(java.lang.Object), java.util.AbstractCollection#isEmpty(), java.util.AbstractCollection#addAll(java.util.Collection), java.util.AbstractCollection#iterator(), java.util.AbstractCollection#size(), java.util.AbstractCollection#toArray(), java.util.AbstractCollection#toArray([Ljava.lang.Object;), java.util.AbstractCollection#remove(java.lang.Object), java.util.AbstractCollection#containsAll(java.util.Collection), java.util.AbstractCollection#removeAll(java.util.Collection), java.util.AbstractCollection#retainAll(java.util.Collection), java.util.AbstractCollection#wait(long), java.util.AbstractCollection#wait(), java.util.AbstractCollection#wait(long, int), java.util.AbstractCollection#equals(java.lang.Object), java.util.AbstractCollection#hashCode(), java.util.AbstractCollection#getClass(), java.util.AbstractCollection#notify(), java.util.AbstractCollection#notifyAll()
 

Field Detail

cchm

final CustomConcurrentHashMap cchm


 
Constructor Detail

CustomConcurrentHashMap.KeySet

public CustomConcurrentHashMap.KeySet(Strength strength, Equivalence equivalence, int expectedSize)
Creates a set with the given parameters
Parameters:
strength - the strength of elements
equivalence - the Equivalence to use
expectedSize - an estimate of the number of elements that will be held in the set. If no estimate is known, zero is an acceptable value.


 
Method Detail

add

public boolean add(java.lang.Object e)
Adds the specified element to this set if there is not already an element equivalent to the given element with respect to this set's Equivalence.
Parameters:
e - element to be added to this set
Returns:
true if this set did not already contain the specified element


clear

public void clear()
Removes all of the elements from this set.


contains

public boolean contains(java.lang.Object o)
Returns true if this set contains an element equivalent to the given element with respect to this set's Equivalence.
Parameters:
o - element whose presence in this set is to be tested
Returns:
true if this set contains the specified element


hashCode

public int hashCode()
Returns the sum of the hash codes of each element, as computed by this set's Equivalence.
Returns:
the hash code


intern

public java.lang.Object intern(java.lang.Object e)
Returns an element equivalent to the given element with respect to this set's Equivalence, if such an element exists, else adds and returns the given element.
Parameters:
e - the element
Returns:
e, or an element equivalent to e.


isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.
Returns:
true if this set contains no elements


iterator

public java.util.Iterator iterator()
Returns a weakly consistent iterator over the elements in this set, that may reflect some, all or none of the changes made to the set after the iterator was created.
Returns:
an Iterator over the elements in this set


remove

public boolean remove(java.lang.Object o)
Removes an element equivalent to the given element with respect to this set's Equivalence, if one is present.
Parameters:
o - object to be removed from this set, if present
Returns:
true if the set contained the specified element


size

public int size()
Returns the number of elements in this set (its cardinality).
Returns:
the number of elements in this set (its cardinality)


 

Copyright © 2008–2012 Václav Pech. All Rights Reserved.