java.lang.Object
org.bzdev.util.DisjointSortedSetsUnion<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
Set implementation backed by a collection of disjoint sets.
The set is immutable in that elements cannot be added explicitly -
only the sets it backs can be modified . These sets must be
disjoint for the iterator to not contain duplicate entries and for
size() and hashCode() to return the correct values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
spliterator
-
Constructor Details
-
DisjointSortedSetsUnion
Constructor. When this constructor is used, additional sets cannot be added and the iterator preserves order. The elements in each set must implement the Comparable interface (checked at runtime) and the set implementations must produce elements in ascending order.Typically, each set will be a TreeSet<E>, although any other Set implementation that provides the desired ordering can be used.
- Parameters:
set1
- the first setset2
- the second set
-
-
Method Details
-
add
-
addAll
-
clear
public void clear() -
equals
-
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty() -
iterator
-
remove
-
removeAll
-
retainAll
-
size
public int size() -
toArray
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Throws:
ArrayStoreException
NullPointerException
-