Package dev.nm.misc.datastructure
Class IdentityHashSet<T>
- java.lang.Object
-
- dev.nm.misc.datastructure.IdentityHashSet<T>
-
- Type Parameters:
T
- a type
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
public class IdentityHashSet<T> extends Object implements Set<T>
This class implements the Set interface with a hash table, using reference-equality in place of object-equality when comparing keys and values.- See Also:
- Bug issue #4479578
-
-
Constructor Summary
Constructors Constructor Description IdentityHashSet()
Construct an emptyIdentityHashSet
.IdentityHashSet(Collection<T> col)
Construct anIdentityHashSet
with a collection of items.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T e)
boolean
addAll(Collection<? extends T> c)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
boolean
equals(Object obj)
int
hashCode()
boolean
isEmpty()
Iterator<T>
iterator()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] a)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
IdentityHashSet
public IdentityHashSet()
Construct an emptyIdentityHashSet
.
-
IdentityHashSet
public IdentityHashSet(Collection<T> col)
Construct anIdentityHashSet
with a collection of items.- Parameters:
col
- a collection of items
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
add
public boolean add(T e)
-
remove
public boolean remove(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
addAll
public boolean addAll(Collection<? extends T> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
clear
public void clear()
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
-