Package org.tweetyproject.arg.adf.util
Class UnionSetView<E>
java.lang.Object
java.util.AbstractCollection<E>
org.tweetyproject.arg.adf.util.AbstractUnmodifiableCollection<E>
org.tweetyproject.arg.adf.util.UnionSetView<E>
- Type Parameters:
E
- the type of elements in this set
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
A view that provides the union of two disjoint sets as a single set.
This class does not copy the elements from the sets but merely wraps them.
It is expected that the two sets are disjoint, as methods like
size()
assume that there is no overlap between the elements.
This class provides an unmodifiable view and all modification operations
will throw UnsupportedOperationException
.
- Author:
- Mathias Hofer
-
Constructor Summary
ConstructorDescriptionUnionSetView
(Set<? extends E> set1, Set<? extends E> set2) Expects the two sets to be disjoint, otherwise some methods, e.g. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
containsAll
(Collection<?> c) boolean
isEmpty()
iterator()
static <E> Set
<E> Creates aUnionSetView
that represents the union of three sets.int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class org.tweetyproject.arg.adf.util.AbstractUnmodifiableCollection
add, addAll, clear, remove, removeAll, removeIf, retainAll
Methods inherited from class java.util.AbstractCollection
toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
UnionSetView
Expects the two sets to be disjoint, otherwise some methods, e.g.size()
, will return unreasonable results.It is up to the caller to ensure this property, this class performs no additional checks.
- Parameters:
set1
- the first setset2
- the second set
-
-
Method Details
-
of
Creates aUnionSetView
that represents the union of three sets.This static method combines the given three sets into a single unified view, where all elements from the three sets appear as one set. It does not create a new set but provides a view representing the union of the specified sets.
- Type Parameters:
E
- The type of elements contained in the sets.- Parameters:
set1
- The first set to be included in the union.set2
- The second set to be included in the union.set3
- The third set to be included in the union.- Returns:
- A
UnionSetView
representing the union of the three sets. - Throws:
NullPointerException
- if any ofset1
,set2
, orset3
isnull
.
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-