Class IdentityHashSet
- java.lang.Object
-
- java.util.AbstractCollection
-
- org.eclipse.persistence.internal.helper.IdentityHashSet
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable,java.util.Collection,java.util.Set
public class IdentityHashSet extends java.util.AbstractCollection implements java.util.Set, java.lang.Cloneable, java.io.Serializable- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcountprotected org.eclipse.persistence.internal.helper.IdentityHashSet.Entry[]entriesprotected floatloadFactorprotected intthreshold
-
Constructor Summary
Constructors Constructor Description IdentityHashSet()Constructs a new IdentityHashSet with a default initial capacity of 32 and a loadfactor of 0.75.IdentityHashSet(int initialCapacity)Constructs a new IdentityHashSet with the given initial capacity and a default loadFactor of 0.75.IdentityHashSet(int initialCapacity, float loadFactor)Constructs a new IdentityHashSet with the given initial capacity and the given loadFactor.IdentityHashSet(java.util.Collection c)Constructs a new IdentityHashSet with the same contents as the given Collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object obj)Adds the given object to this IdentityHashSet.voidclear()Removes all of the objects from this IdentityHashSet.java.lang.Objectclone()Returns a shallow copy of this IdentityHashSet (the elements are not cloned).booleancontains(java.lang.Object obj)Returns true if this IdentityHashSet contains the given object.booleanisEmpty()java.util.Iteratoriterator()Get an iterator for this IdentityHashSetbooleanremove(java.lang.Object obj)Removes the given object from this IdentityHashSet, if present.booleanremoveAll(java.util.Collection c)This implementation throws an UnsupportedOperationException because removeAll does not work correctly with reference equality testing.booleanretainAll(java.util.Collection c)This implementation throws an UnsupportedOperationException.intsize()-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, toArray, toArray, toString
-
-
-
-
Constructor Detail
-
IdentityHashSet
public IdentityHashSet(int initialCapacity, float loadFactor)Constructs a new IdentityHashSet with the given initial capacity and the given loadFactor.- Parameters:
initialCapacity- the initial capacity of the IdentityHashSet.loadFactor- the loadFactor of the IdentityHashSet.
-
IdentityHashSet
public IdentityHashSet(int initialCapacity)
Constructs a new IdentityHashSet with the given initial capacity and a default loadFactor of 0.75.- Parameters:
initialCapacity- the initial capacity of the IdentityHashSet.
-
IdentityHashSet
public IdentityHashSet()
Constructs a new IdentityHashSet with a default initial capacity of 32 and a loadfactor of 0.75.
-
IdentityHashSet
public IdentityHashSet(java.util.Collection c)
Constructs a new IdentityHashSet with the same contents as the given Collection. The new IdentityHashSet is created with an initial capacity sufficient to hold the elements of the given Collection.- Parameters:
c- the Collection whose contents are to be placed in the new IdentityHashSet.
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection- Specified by:
sizein interfacejava.util.Set- Specified by:
sizein classjava.util.AbstractCollection- Returns:
- the size of this IdentityHashSet.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection- Specified by:
isEmptyin interfacejava.util.Set- Overrides:
isEmptyin classjava.util.AbstractCollection- Returns:
- true if this IdentityHashSet is empty.
-
contains
public boolean contains(java.lang.Object obj)
Returns true if this IdentityHashSet contains the given object.- Specified by:
containsin interfacejava.util.Collection- Specified by:
containsin interfacejava.util.Set- Overrides:
containsin classjava.util.AbstractCollection- Parameters:
obj- the object to find.- Returns:
- true if this IdentityHashSet contains obj by reference.
-
add
public boolean add(java.lang.Object obj)
Adds the given object to this IdentityHashSet.- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.Set- Overrides:
addin classjava.util.AbstractCollection- Parameters:
obj- object to add.- Returns:
- true if this IdentityHashSet did not already contain obj.
-
remove
public boolean remove(java.lang.Object obj)
Removes the given object from this IdentityHashSet, if present.- Specified by:
removein interfacejava.util.Collection- Specified by:
removein interfacejava.util.Set- Overrides:
removein classjava.util.AbstractCollection- Parameters:
obj- the object to be removed from this IdentityHashSet.- Returns:
- true if this IdentityHashSet contained obj.
-
removeAll
public boolean removeAll(java.util.Collection c)
This implementation throws an UnsupportedOperationException because removeAll does not work correctly with reference equality testing.- Specified by:
removeAllin interfacejava.util.Collection- Specified by:
removeAllin interfacejava.util.Set- Overrides:
removeAllin classjava.util.AbstractCollection
-
retainAll
public boolean retainAll(java.util.Collection c)
This implementation throws an UnsupportedOperationException. The Javadocs forAbstractCollectionindicates that retainAll is an optional method.- Specified by:
retainAllin interfacejava.util.Collection- Specified by:
retainAllin interfacejava.util.Set- Overrides:
retainAllin classjava.util.AbstractCollection
-
clear
public void clear()
Removes all of the objects from this IdentityHashSet.- Specified by:
clearin interfacejava.util.Collection- Specified by:
clearin interfacejava.util.Set- Overrides:
clearin classjava.util.AbstractCollection
-
clone
public java.lang.Object clone()
Returns a shallow copy of this IdentityHashSet (the elements are not cloned).- Overrides:
clonein classjava.lang.Object- Returns:
- a shallow copy of this IdentityHashSet.
-
iterator
public java.util.Iterator iterator()
Get an iterator for this IdentityHashSet- Specified by:
iteratorin interfacejava.util.Collection- Specified by:
iteratorin interfacejava.lang.Iterable- Specified by:
iteratorin interfacejava.util.Set- Specified by:
iteratorin classjava.util.AbstractCollection
-
-