public final class IdentitySet<T> extends AbstractSet<T> implements Set<T>
Set implementation that considers objects equal if an only if they are the same instance. The
Object.equals(Object) and Object.hashCode() methods of the stored objects are ingored.
This implementation uses another Set to store IdentitySet.IdentityReference
objects for each object in the set.
| Modifier and Type | Class and Description |
|---|---|
static class |
IdentitySet.IdentityReference<T>
Stores a reference to any Object.
|
| Constructor and Description |
|---|
IdentitySet(Set<IdentitySet.IdentityReference<T>> delegateSet)
Create a new set using the passed set as the store.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T t) |
boolean |
addAll(Collection<? extends T> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
static <T> IdentitySet<T> |
newListOrderedSet()
Create a new identity set.
|
static <T> IdentitySet<T> |
newSet()
Create a new identity set.
|
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
String |
toString() |
equals, hashCodetoArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitparallelStream, removeIf, streampublic IdentitySet(Set<IdentitySet.IdentityReference<T>> delegateSet)
delegateSet - the set actually store the objects.public static <T> IdentitySet<T> newSet()
T - the objects to be stored in the identity set.public static <T> IdentitySet<T> newListOrderedSet()
T - the objects to be stored in the identity set.public void clear()
clear in interface Collection<T>clear in interface Set<T>clear in class AbstractCollection<T>public boolean add(T t)
add in interface Collection<T>add in interface Set<T>add in class AbstractCollection<T>public boolean remove(Object o)
remove in interface Collection<T>remove in interface Set<T>remove in class AbstractCollection<T>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>containsAll in interface Set<T>containsAll in class AbstractCollection<T>public boolean addAll(Collection<? extends T> c)
addAll in interface Collection<T>addAll in interface Set<T>addAll in class AbstractCollection<T>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<T>retainAll in interface Set<T>retainAll in class AbstractCollection<T>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<T>removeAll in interface Set<T>removeAll in class AbstractSet<T>public int size()
size in interface Collection<T>size in interface Set<T>size in class AbstractCollection<T>public boolean isEmpty()
isEmpty in interface Collection<T>isEmpty in interface Set<T>isEmpty in class AbstractCollection<T>public boolean contains(Object o)
contains in interface Collection<T>contains in interface Set<T>contains in class AbstractCollection<T>public String toString()
toString in class AbstractCollection<T>Copyright © 2002-2020 Atlassian. All Rights Reserved.