|
|||||||||
| 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.Collectionsize in interface java.util.Setsize in class java.util.AbstractCollectionpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in interface java.util.Setiterator in class java.util.AbstractCollectionpublic boolean contains(java.lang.Object o)
contains in interface java.util.Collectioncontains in interface java.util.Setcontains in class java.util.AbstractCollectionpublic boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in interface java.util.Setadd in class java.util.AbstractCollectionpublic boolean remove(java.lang.Object o)
remove in interface java.util.Collectionremove in interface java.util.Setremove in class java.util.AbstractCollectionpublic java.lang.Object get(int index)
get in interface IndexedSetjava.lang.IndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())public int indexOf(java.lang.Object o)
indexOf in interface IndexedSetpublic java.util.Set getAdditions()
getAdditions in interface SetDiffpublic java.util.Set getRemovals()
getRemovals in interface SetDiffpublic void changeUnderlying()
changeUnderlying in interface SetDiffpublic void clearChanges()
clearChanges in interface SetDiffpublic java.lang.Object clone()
clone in class java.lang.Objectpublic static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||