T - the type of object stored by this classpublic class ClassIndexedSet<T>
extends java.util.AbstractSet<T>
implements java.util.Set<T>
| Modifier and Type | Class and Description |
|---|---|
protected class |
ClassIndexedSet.ClassIndexedSetIterator
Iterator for set implementation
ClassIndexedSet. |
| Modifier and Type | Field and Description |
|---|---|
private java.util.HashMap<java.lang.Class<? extends T>,T> |
index
Storage for index of class -> member.
|
private java.util.HashSet<T> |
set
Storage for set members.
|
| Constructor and Description |
|---|
ClassIndexedSet()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T o) |
boolean |
add(T o,
boolean replace)
Add member to set, optionally replacing any existing instance of the same class.
|
void |
clear() |
boolean |
contains(java.lang.Class<? extends T> clazz)
Check whether set contains an instance of the specified class.
|
boolean |
equals(java.lang.Object obj) |
<X extends T> |
get(java.lang.Class<X> clazz)
Get the set element specified by the class parameter.
|
protected <X extends T> |
getIndexClass(X o)
Get the index class of the specified object.
|
int |
hashCode() |
java.util.Iterator<T> |
iterator() |
boolean |
remove(java.lang.Object o) |
private void |
removeFromIndex(T o)
Remove the specified object from the index.
|
int |
size() |
java.lang.String |
toString() |
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitprivate final java.util.HashSet<T> set
public boolean add(@Nonnull
T o)
public boolean add(@Nonnull
T o,
boolean replace)
o - the object to addreplace - flag indicating whether to replace an existing class typepublic void clear()
public boolean remove(@Nullable
java.lang.Object o)
@Nonnull public java.util.Iterator<T> iterator()
public int size()
public boolean contains(@Nullable
java.lang.Class<? extends T> clazz)
clazz - the class to check@Nullable public <X extends T> X get(@Nullable java.lang.Class<X> clazz)
X - generic parameter which eliminates need for casting by the callerclazz - the class to whose instance is to be retrieved@Nonnull protected <X extends T> java.lang.Class<X> getIndexClass(@Nonnull X o)
X - generic parameter which eliminates need for casting by the callero - the object whose class index to determineprivate void removeFromIndex(T o)
o - the object to removepublic java.lang.String toString()
toString in class java.util.AbstractCollection<T>public boolean equals(java.lang.Object obj)