public class SubSet<E> extends AbstractSet<E> implements Cloneable
iterator() will iterate items in the ascending order.
This implementation is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
protected class |
SubSet.SubSetIterator
Iterator for the contents of a subset in the "removed" mode.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_fRetained
Toggles between whether the modifications are removed or retained.
|
protected Set<E> |
m_setMod
The removed or retained items.
|
protected Set<E> |
m_setOrig
The underlying set (assumed immutable).
|
| Constructor and Description |
|---|
SubSet(Set<? extends E> set)
Construct this set based on an existing set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> col) |
void |
clear() |
Object |
clone()
Clone the subset.
|
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> col) |
protected Set<E> |
ensureRemoved()
Get a mutable set of items that are removed in the subset.
|
protected Set<E> |
ensureRetained()
Get a mutable set of items that are retained in the subset.
|
Set<? extends E> |
getOriginal()
Determine what items were in the original set.
|
Set<E> |
getRemoved()
Determine what items were removed from the subset.
|
Set<E> |
getRetained()
Determine what items were added to the subset.
|
protected Set<E> |
instantiateModificationSet(int cSize)
Instantiate a new modification set containing either removed or retained items.
|
boolean |
isEmpty() |
boolean |
isModified()
Determine if the set has been modified.
|
boolean |
isTrackingRetained()
Determine if the SubSet is tracking retained items versus removed items.
|
Iterator |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> col) |
void |
reset()
Discard the changes to the set ("rollback").
|
protected void |
resetState(Set setOrig, Set setMod, boolean fRetained)
Reset the state of the subset according to the specified parameters.
|
void |
resolve()
Apply the changes to the underlying set ("commit").
|
boolean |
retainAll(Collection<?> col) |
protected void |
retainAllInternal(Collection colOuter, Collection colMatch, Set setExclude)
Instantiate a new retained set with all elements in the specified collection that also exist in the provided
colMatch collection and are not excluded. |
int |
size() |
Object[] |
toArray() |
Object[] |
toArray(Object[] ao) |
equals, hashCodetoStringfinalize, getClass, notify, notifyAll, wait, wait, waitspliteratorparallelStream, removeIf, streamprotected boolean m_fRetained
public Set<? extends E> getOriginal()
public boolean isModified()
public boolean isTrackingRetained()
public Set<E> getRetained()
public Set<E> getRemoved()
protected Set<E> instantiateModificationSet(int cSize)
cSize - an initial size of the modification setprotected Set<E> ensureRetained()
protected Set<E> ensureRemoved()
public void resolve()
public void reset()
protected void resetState(Set setOrig, Set setMod, boolean fRetained)
setOrig - the new original setsetMod - the set of removed or retained entries, depending on the fRetained flagfRetained - if true setMod contains the retained entries; otherwise the removed entriespublic Iterator iterator()
public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public boolean containsAll(Collection<?> col)
containsAll in interface Collection<E>containsAll in interface Set<E>containsAll in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>public boolean addAll(Collection<? extends E> col)
addAll in interface Collection<E>addAll in interface Set<E>addAll in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>public boolean removeAll(Collection<?> col)
removeAll in interface Collection<E>removeAll in interface Set<E>removeAll in class AbstractSet<E>public boolean retainAll(Collection<?> col)
retainAll in interface Collection<E>retainAll in interface Set<E>retainAll in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public Object[] toArray(Object[] ao)
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public Object clone()
protected void retainAllInternal(Collection colOuter, Collection colMatch, Set setExclude)
colMatch collection and are not excluded.colOuter - collection to iteratecolMatch - each element in colOuter should be present in this collection such that (colOuter ∩ colMatch)setExclude - optional set of excluded elements