|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet
common.IndexedHashSetDiff
public class IndexedHashSetDiff
Implementation of the IndexedSet interface that is represented as a set of differences from an underlying IndexedSet.
An IndexedHashSetDiff will behave correctly if objects are added to the underlying set after the IndexedHashSetDiff is created, as long as these objects have not also been added to the IndexedHashSetDiff (then they would be double-counted). Removing objects from the underlying set may cause an IndexedHashSetDiff to behave incorrectly, because it may change the indices of elements of the underlying set.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface common.IndexedSet |
---|
IndexedSet.EmptyIndexedSet |
Field Summary |
---|
Fields inherited from interface common.IndexedSet |
---|
EMPTY_INDEXED_SET |
Constructor Summary | |
---|---|
IndexedHashSetDiff(IndexedSet underlying)
Creates a new IndexedHashSetDiff with the given underlying IndexedSet. |
Method Summary | |
---|---|
boolean |
add(java.lang.Object o)
Adds the given object to this IndexedSet, with an index equal to the previous size of the set. |
void |
changeUnderlying()
Changes the underlying IndexedSet so it is equal to this one, and clears the changes in this IndexedSetDiff. |
void |
clearChanges()
Clears the changes in this IndexedSetDiff so it is once again equal to the underlying IndexedSet. |
java.lang.Object |
clone()
|
boolean |
contains(java.lang.Object o)
|
java.lang.Object |
get(int index)
Returns the object with the specified index in this IndexedSet. |
java.util.Set |
getAdditions()
Returns the set of objects that are in this set and not the underlying set. |
java.util.Set |
getRemovals()
Returns the set of objects that are in the underlying set but not in this set. |
int |
indexOf(java.lang.Object o)
Returns the index of the given object in this IndexedSet, or -1 if this IndexedSet does not contain the given object. |
java.util.Iterator |
iterator()
Returns an iterator that is robust to additions to this IndexedSetDiff and additions to the underlying set. |
static void |
main(java.lang.String[] args)
Test program. |
boolean |
remove(java.lang.Object o)
Removes the given object from this IndexedSet if it was present. |
int |
size()
|
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public IndexedHashSetDiff(IndexedSet underlying)
Method Detail |
---|
public int size()
size
in interface java.util.Collection
size
in interface java.util.Set
size
in class java.util.AbstractCollection
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.Set
iterator
in class java.util.AbstractCollection
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
contains
in interface java.util.Set
contains
in class java.util.AbstractCollection
public boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.Set
add
in class java.util.AbstractCollection
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection
remove
in interface java.util.Set
remove
in class java.util.AbstractCollection
public java.lang.Object get(int index)
get
in interface IndexedSet
java.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()
)public int indexOf(java.lang.Object o)
indexOf
in interface IndexedSet
public java.util.Set getAdditions()
getAdditions
in interface SetDiff
public java.util.Set getRemovals()
getRemovals
in interface SetDiff
public void changeUnderlying()
changeUnderlying
in interface SetDiff
public void clearChanges()
clearChanges
in interface SetDiff
public java.lang.Object clone()
clone
in class java.lang.Object
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |