java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
com.aoapps.collections.UnionSet<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
In order to efficiently provide a union of fewer, larger sets, this provides a
set view on top of other sets. Any set that is added to this union set via
addAll(Set) must not be modified after being added. For
performance purposes, defensive copying is not performed.- Author:
- AO Industries, Inc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) Triggers combining.voidIf the set has size > MAXIMUM_COMBINE_SIZE, the set will be added to theaddedlist, which may then be later combined only when needed.voidclear()booleanbooleancontainsAll(Collection<?> c) booleanisEmpty()iterator()Triggers combining.booleanTriggers combining.booleanremoveAll(Collection<?> c) Triggers combining.booleanretainAll(Collection<?> c) Triggers combining.intsize()Triggers combining.Object[]toArray()Triggers combining.<T> T[]toArray(T[] a) Triggers combining.Methods inherited from class java.util.AbstractSet
equals, hashCodeMethods inherited from class java.util.AbstractCollection
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
Constructor Details
-
UnionSet
public UnionSet() -
UnionSet
-
UnionSet
-
-
Method Details
-
size
public int size()Triggers combining.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
iterator
Triggers combining.TODO: Iterate without combining - benchmark speed versus complexity
-
toArray
Triggers combining.- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) Triggers combining.- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classAbstractCollection<E>
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>
-
remove
Triggers combining.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Overrides:
containsAllin classAbstractCollection<E>
-
addAll
Triggers combining.- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceSet<E>- Overrides:
addAllin classAbstractCollection<E>- See Also:
-
addAll
If the set has size > MAXIMUM_COMBINE_SIZE, the set will be added to theaddedlist, which may then be later combined only when needed. Because of this potentially delayed combining, any set added should not be subsequently altered. -
retainAll
Triggers combining.- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceSet<E>- Overrides:
retainAllin classAbstractCollection<E>
-
removeAll
Triggers combining.- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classAbstractSet<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
