- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- com.aoapps.collections.UnionClassSet<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
public class UnionClassSet<E> extends AbstractSet<E>
A union set that assumes objects of different classes are not equal. It never does any combining. The following assumptions are made:- All elements of the added sets are of the same exact class
- Objects of different classes are not equal.
- No set will contain
null - A set for a specific class may only be added once.
- Sets that have been added do not change after being added.
- Only sets will be added.
- Nothing will be removed (except clear is supported).
- Author:
- AO Industries, Inc.
-
-
Constructor Summary
Constructors Constructor Description UnionClassSet()UnionClassSet(Collection<? extends E> c)UnionClassSet(Set<? extends E> set)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAll(Collection<? extends E> c)Must be a set.booleanaddAll(Set<? extends E> set)voidclear()booleancontains(Object o)Iterator<E>iterator()intsize()-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
add, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
add, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
UnionClassSet
public UnionClassSet()
-
UnionClassSet
public UnionClassSet(Collection<? extends E> c)
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
Must be a set.- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceSet<E>- Overrides:
addAllin classAbstractCollection<E>- See Also:
addAll(java.util.Set)
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
-