Module org.eclipse.persistence.core
Class IdentityHashSet
- java.lang.Object
-
- java.util.AbstractCollection
-
- org.eclipse.persistence.internal.helper.IdentityHashSet
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable,Collection,Set
public class IdentityHashSet extends AbstractCollection implements Set, Cloneable, Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcountprotected floatloadFactorprotected intthreshold
-
Constructor Summary
Constructors Constructor Description IdentityHashSet()Constructs a newIdentityHashSetwith a default initial capacity of32and a loadfactor of0.75.IdentityHashSet(int initialCapacity)Constructs a newIdentityHashSetwith the given initial capacity and a default loadFactor of0.75.IdentityHashSet(int initialCapacity, float loadFactor)Constructs a newIdentityHashSetwith the given initial capacity and the given loadFactor.IdentityHashSet(Collection c)Constructs a newIdentityHashSetwith the same contents as the givenCollection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Object obj)Adds the given object to thisIdentityHashSet.voidclear()Removes all of the objects from thisIdentityHashSet.Objectclone()Returns a shallow copy of thisIdentityHashSet(the elements are not cloned).booleancontains(Object obj)Returnstrueif thisIdentityHashSetcontains the given object.booleanisEmpty()Iteratoriterator()Get an iterator for thisIdentityHashSetbooleanremove(Object obj)Removes the given object from thisIdentityHashSet, if present.booleanremoveAll(Collection c)This implementation throws anUnsupportedOperationExceptionbecauseremoveAlldoes not work correctly with reference equality testing.booleanretainAll(Collection c)This implementation throws anUnsupportedOperationException.intsize()-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
IdentityHashSet
public IdentityHashSet(int initialCapacity, float loadFactor)Constructs a newIdentityHashSetwith the given initial capacity and the given loadFactor.- Parameters:
initialCapacity- the initial capacity of theIdentityHashSet.loadFactor- the loadFactor of theIdentityHashSet.- Throws:
IllegalArgumentException- if the initial capacity is less than zero, or if the loadFactor is nonpositive.
-
IdentityHashSet
public IdentityHashSet(int initialCapacity)
Constructs a newIdentityHashSetwith the given initial capacity and a default loadFactor of0.75.- Parameters:
initialCapacity- the initial capacity of the IdentityHashSet.- Throws:
IllegalArgumentException- if the initial capacity is less than zero.
-
IdentityHashSet
public IdentityHashSet()
Constructs a newIdentityHashSetwith a default initial capacity of32and a loadfactor of0.75.
-
IdentityHashSet
public IdentityHashSet(Collection c)
Constructs a newIdentityHashSetwith the same contents as the givenCollection. The newIdentityHashSetis created with an initial capacity sufficient to hold the elements of the givenCollection.- Parameters:
c- theCollectionwhose contents are to be placed in the newIdentityHashSet.
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceSet- Specified by:
sizein classAbstractCollection- Returns:
- the size of this
IdentityHashSet.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceSet- Overrides:
isEmptyin classAbstractCollection- Returns:
trueif thisIdentityHashSetis empty.
-
contains
public boolean contains(Object obj)
Returnstrueif thisIdentityHashSetcontains the given object.- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet- Overrides:
containsin classAbstractCollection- Parameters:
obj- the object to find.- Returns:
- true if this
IdentityHashSetcontains obj by reference.
-
add
public boolean add(Object obj)
Adds the given object to thisIdentityHashSet.- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet- Overrides:
addin classAbstractCollection- Parameters:
obj- object to add.- Returns:
trueif thisIdentityHashSetdid not already contain obj.- Throws:
NullPointerException- if obj is null.
-
remove
public boolean remove(Object obj)
Removes the given object from thisIdentityHashSet, if present.- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet- Overrides:
removein classAbstractCollection- Parameters:
obj- the object to be removed from thisIdentityHashSet.- Returns:
trueif thisIdentityHashSetcontained obj.
-
removeAll
public boolean removeAll(Collection c)
This implementation throws anUnsupportedOperationExceptionbecauseremoveAlldoes not work correctly with reference equality testing.- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet- Overrides:
removeAllin classAbstractCollection
-
retainAll
public boolean retainAll(Collection c)
This implementation throws anUnsupportedOperationException. The Javadocs forAbstractCollectionindicates thatretainAllis an optional method.- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet- Overrides:
retainAllin classAbstractCollection
-
clear
public void clear()
Removes all of the objects from thisIdentityHashSet.- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet- Overrides:
clearin classAbstractCollection
-
clone
public Object clone()
Returns a shallow copy of thisIdentityHashSet(the elements are not cloned).
-
iterator
public Iterator iterator()
Get an iterator for thisIdentityHashSet- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Specified by:
iteratorin interfaceSet- Specified by:
iteratorin classAbstractCollection
-
-