Package com.tangosol.util
Class DeltaSet
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet
-
- com.tangosol.util.DeltaSet
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable,Collection,Set
public class DeltaSet extends AbstractSet implements Cloneable, Serializable
Implements a set which is based on another set, which is assumed to be immutable.- Version:
- 1.00, 11/30/98
- Author:
- Cameron Purdy
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDeltaSet.DeltaIteratorIterator for the contents of a delta set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Object o)Ensures that this Collection contains the specified element.voidclear()Removes all of the elements from this Collection.Objectclone()Clone the delta set.booleancontains(Object o)Returns true if this Collection contains the specified element.protected SetensureAdded()Get a mutable set of items that were added to the delta set.protected SetensureRemoved()Get a mutable set of items that were removed from the delta set.SetgetAdded()Determine what items were added to the delta set.SetgetOriginal()Determine what items were in the original set.SetgetRemoved()Determine what items were removed from the delta set.booleanisModified()Determine if any items were added or removed.Iteratoriterator()Returns an Iterator over the elements contained in this Collection.booleanremove(Object o)Removes a single instance of the specified element from this Collection, if it is present (optional operation).voidreset()Discard the changes to the set ("rollback").voidresolve()Apply the changes to the underlying set ("commit").intsize()Returns the number of elements in this Collection.Object[]toArray()Returns an array containing all of the elements in this Set.-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toString
-
Methods inherited from class java.lang.Object
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
addAll, containsAll, isEmpty, retainAll, spliterator, toArray
-
-
-
-
Constructor Detail
-
DeltaSet
public DeltaSet(Set set)
Construct this set based on an existing set.- Parameters:
set- the set to base this delta set on
-
-
Method Detail
-
getOriginal
public Set getOriginal()
Determine what items were in the original set.- Returns:
- the set used to construct this DeltaSet
-
isModified
public boolean isModified()
Determine if any items were added or removed.- Returns:
- true if the set has been modified
-
getAdded
public Set getAdded()
Determine what items were added to the delta set.- Returns:
- an immutable set of added items
-
getRemoved
public Set getRemoved()
Determine what items were removed from the delta set.- Returns:
- an immutable set of removed items
-
ensureAdded
protected Set ensureAdded()
Get a mutable set of items that were added to the delta set.- Returns:
- a mutable set of added items
-
ensureRemoved
protected Set ensureRemoved()
Get a mutable set of items that were removed from the delta set.- Returns:
- a mutable set of removed items
-
resolve
public void resolve()
Apply the changes to the underlying set ("commit").
-
reset
public void reset()
Discard the changes to the set ("rollback").
-
iterator
public Iterator iterator()
Returns an Iterator over the elements contained in this Collection.- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Specified by:
iteratorin interfaceSet- Specified by:
iteratorin classAbstractCollection- Returns:
- an Iterator over the elements contained in this Collection
-
size
public int size()
Returns the number of elements in this Collection.- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceSet- Specified by:
sizein classAbstractCollection- Returns:
- the number of elements in this Collection
-
contains
public boolean contains(Object o)
Returns true if this Collection contains the specified element. More formally, returns true if and only if this Collection contains at least one elementesuch that(o==null ? e==null : o.equals(e)).- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet- Overrides:
containsin classAbstractCollection- Parameters:
o- the object to search for in the set- Returns:
- true if this set contains the specified object
-
add
public boolean add(Object o)
Ensures that this Collection contains the specified element.- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet- Overrides:
addin classAbstractCollection- Parameters:
o- element whose presence in this Collection is to be ensured- Returns:
- true if the Collection changed as a result of the call
-
remove
public boolean remove(Object o)
Removes a single instance of the specified element from this Collection, if it is present (optional operation). More formally, removes an elementesuch that(o==null ? e==null : o.equals(e)), if the Collection contains one or more such elements. Returns true if the Collection contained the specified element (or equivalently, if the Collection changed as a result of the call).- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet- Overrides:
removein classAbstractCollection- Parameters:
o- element to be removed from this Collection, if present- Returns:
- true if the Collection contained the specified element
-
clear
public void clear()
Removes all of the elements from this Collection.- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet- Overrides:
clearin classAbstractCollection
-
toArray
public Object[] toArray()
Returns an array containing all of the elements in this Set. Obeys the general contract of Collection.toArray.- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet- Overrides:
toArrayin classAbstractCollection- Returns:
- an Object array containing all of the elements in this Set
-
-