|
||||||||||
| 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
net.spy.util.ReferenceSet
public abstract class ReferenceSet
This class aids in implementing sets of references.
| Constructor Summary | |
|---|---|
ReferenceSet()
Get an instance of ReferenceSet. |
|
ReferenceSet(java.util.Collection c)
Get a ReferenceSet with the contents from the given Collection. |
|
ReferenceSet(int n)
Create a ReferenceSet with the given capacity. |
|
| Method Summary | |
|---|---|
boolean |
add(java.lang.Object o)
Add an object to the Set. |
protected abstract java.lang.ref.Reference |
getReference(java.lang.Object o)
Obtain the desired type of reference to the given object. |
java.util.Iterator |
iterator()
Get an iterator. |
int |
size()
Get the current size of the Set. |
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, clear, contains, 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.Set |
|---|
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public ReferenceSet()
public ReferenceSet(int n)
n - the initial capacitypublic ReferenceSet(java.util.Collection c)
c - the collection| Method Detail |
|---|
public boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in interface java.util.Setadd in class java.util.AbstractCollectiono - the object
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.AbstractCollectionprotected abstract java.lang.ref.Reference getReference(java.lang.Object o)
Unfortunately, java doesn't give me a way to enforce this in the language (i.e. at compile time), but subclasses of ReferenceSet must implement hashCode() and equals() in such a way that they return what the referenced object would return if the object were not a reference. If the reference has disappeared, equals() should return false, and hashCode should return 0.
o - an object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||