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 int
count
protected org.eclipse.persistence.internal.helper.IdentityHashSet.Entry[]
entries
protected float
loadFactor
protected int
threshold
-
Constructor Summary
Constructors Constructor Description IdentityHashSet()
Constructs a newIdentityHashSet
with a default initial capacity of32
and a loadfactor of0.75
.IdentityHashSet(int initialCapacity)
Constructs a newIdentityHashSet
with the given initial capacity and a default loadFactor of0.75
.IdentityHashSet(int initialCapacity, float loadFactor)
Constructs a newIdentityHashSet
with the given initial capacity and the given loadFactor.IdentityHashSet(Collection c)
Constructs a newIdentityHashSet
with the same contents as the givenCollection
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Object obj)
Adds the given object to thisIdentityHashSet
.void
clear()
Removes all of the objects from thisIdentityHashSet
.Object
clone()
Returns a shallow copy of thisIdentityHashSet
(the elements are not cloned).boolean
contains(Object obj)
Returnstrue
if thisIdentityHashSet
contains the given object.boolean
isEmpty()
Iterator
iterator()
Get an iterator for thisIdentityHashSet
boolean
remove(Object obj)
Removes the given object from thisIdentityHashSet
, if present.boolean
removeAll(Collection c)
This implementation throws anUnsupportedOperationException
becauseremoveAll
does not work correctly with reference equality testing.boolean
retainAll(Collection c)
This implementation throws anUnsupportedOperationException
.int
size()
-
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
-
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 newIdentityHashSet
with 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 newIdentityHashSet
with 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 newIdentityHashSet
with a default initial capacity of32
and a loadfactor of0.75
.
-
IdentityHashSet
public IdentityHashSet(Collection c)
Constructs a newIdentityHashSet
with the same contents as the givenCollection
. The newIdentityHashSet
is created with an initial capacity sufficient to hold the elements of the givenCollection
.- Parameters:
c
- theCollection
whose contents are to be placed in the newIdentityHashSet
.
-
-
Method Detail
-
size
public int size()
- Specified by:
size
in interfaceCollection
- Specified by:
size
in interfaceSet
- Specified by:
size
in classAbstractCollection
- Returns:
- the size of this
IdentityHashSet
.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection
- Specified by:
isEmpty
in interfaceSet
- Overrides:
isEmpty
in classAbstractCollection
- Returns:
true
if thisIdentityHashSet
is empty.
-
contains
public boolean contains(Object obj)
Returnstrue
if thisIdentityHashSet
contains the given object.- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceSet
- Overrides:
contains
in classAbstractCollection
- Parameters:
obj
- the object to find.- Returns:
- true if this
IdentityHashSet
contains obj by reference.
-
add
public boolean add(Object obj)
Adds the given object to thisIdentityHashSet
.- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceSet
- Overrides:
add
in classAbstractCollection
- Parameters:
obj
- object to add.- Returns:
true
if thisIdentityHashSet
did 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:
remove
in interfaceCollection
- Specified by:
remove
in interfaceSet
- Overrides:
remove
in classAbstractCollection
- Parameters:
obj
- the object to be removed from thisIdentityHashSet
.- Returns:
true
if thisIdentityHashSet
contained obj.
-
removeAll
public boolean removeAll(Collection c)
This implementation throws anUnsupportedOperationException
becauseremoveAll
does not work correctly with reference equality testing.- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceSet
- Overrides:
removeAll
in classAbstractCollection
-
retainAll
public boolean retainAll(Collection c)
This implementation throws anUnsupportedOperationException
. The Javadocs forAbstractCollection
indicates thatretainAll
is an optional method.- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceSet
- Overrides:
retainAll
in classAbstractCollection
-
clear
public void clear()
Removes all of the objects from thisIdentityHashSet
.- Specified by:
clear
in interfaceCollection
- Specified by:
clear
in interfaceSet
- Overrides:
clear
in 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:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
- Specified by:
iterator
in interfaceSet
- Specified by:
iterator
in classAbstractCollection
-
-