Package com.atlassian.jira.util.collect
Class IdentitySet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
com.atlassian.jira.util.collect.IdentitySet<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
A
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 ignored.
This implementation uses another Set to store IdentitySet.IdentityReference
objects for each object in the set.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classStores a reference to any Object. -
Constructor Summary
ConstructorsConstructorDescriptionIdentitySet(Set<IdentitySet.IdentityReference<T>> delegateSet) Create a new set using the passed set as the store. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleanisEmpty()iterator()static <T> IdentitySet<T>Create a new identity set.static <T> IdentitySet<T>newSet()Create a new identity set.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()toString()Methods inherited from class java.util.AbstractSet
equals, hashCodeMethods inherited from class java.util.AbstractCollection
toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
IdentitySet
Create a new set using the passed set as the store. The passed set should not be used by the caller while the new IdentitySet is in use.- Parameters:
delegateSet- the set actually store the objects.
-
-
Method Details
-
newSet
Create a new identity set.- Type Parameters:
T- the objects to be stored in the identity set.- Returns:
- the new set.
-
newListOrderedSet
Create a new identity set. The elements in the returned set will be stored in addition order.- Type Parameters:
T- the objects to be stored in the identity set.- Returns:
- the new set.
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceSet<T>- Overrides:
clearin classAbstractCollection<T>
-
iterator
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>- Overrides:
containsAllin classAbstractCollection<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceSet<T>- Overrides:
addAllin classAbstractCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceSet<T>- Overrides:
retainAllin classAbstractCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceSet<T>- Overrides:
removeAllin classAbstractSet<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceSet<T>- Specified by:
sizein classAbstractCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceSet<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
contains
- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceSet<T>- Overrides:
containsin classAbstractCollection<T>
-
toString
- Overrides:
toStringin classAbstractCollection<T>
-