|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<T>
org.semanticweb.elk.util.collections.entryset.KeyEntryHashSet<T>
T - the type of elements in the setpublic class KeyEntryHashSet<T>
A collection containing elements modulo equality. The comparison of elements
is performed by wrapping them into KeyEntry objects where the key is
a specified input element. For this purpose, these objects should redefine
the Object.equals(Object) and Object.hashCode() methods accordingly. A
factory for producing KeyEntry objects from the elements should be
provided during construction of this collection.
The main method provided is merging a entry into collection, which returns an
equal element from the collection, if there is one (according to the
specified way to compare elements), or, otherwise, inserts the input element
into the collection returning itself. Other methods include finding an
element in the collection that is equal to the given one, deleting such an
element from the collection, if found, and iterating over the entries.
| Field Summary | |
|---|---|
protected EntryHashSet<KeyEntry<T,? extends T>> |
entryHashSet
The underlying entry collection used to back this collection |
protected KeyEntryFactory<T> |
keyEntryFactory
The factory used for wrapping keys into entries |
| Constructor Summary | |
|---|---|
KeyEntryHashSet(KeyEntryFactory<T> keyEntryFactory)
Create an empty set associated with a given factory for creating KeyEntry wrapper objects. |
|
KeyEntryHashSet(KeyEntryFactory<T> keyEntryFactory,
int initialCapacity)
Create an empty set associated with a given factory for creating KeyEntry wrapper objects and with the given initial capacity. |
|
| Method Summary | |
|---|---|
boolean |
add(T key)
|
void |
clear()
|
T |
get(T key)
Retrieves the element in the set that is equal to the given object, if it exists, or returns null otherwise. |
Iterator<T> |
iterator()
|
T |
merge(T key)
Get the element in set that is equal to the input entry if there is one, or otherwise insert the given entry into the set and return itself. |
boolean |
remove(Object o)
|
T |
removeEntry(T key)
Removes and returns the element in the set that is equal to the input element. |
int |
size()
|
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode |
| Field Detail |
|---|
protected final KeyEntryFactory<T> keyEntryFactory
protected final EntryHashSet<KeyEntry<T,? extends T>> entryHashSet
| Constructor Detail |
|---|
public KeyEntryHashSet(KeyEntryFactory<T> keyEntryFactory,
int initialCapacity)
KeyEntry wrapper objects and with the given initial capacity. The
set will be resized as necessary to accommodate new elements.
keyEntryFactory - factory for creating KeyEntry wrapper objectsinitialCapacity - the estimatedpublic KeyEntryHashSet(KeyEntryFactory<T> keyEntryFactory)
KeyEntry wrapper objects.
keyEntryFactory - | Method Detail |
|---|
public T merge(T key)
KeyEntry objects using the factory.
key - the element to be merged into the set
public boolean add(T key)
add in interface Collection<T>add in class AbstractCollection<T>public T get(T key)
KeyEntry objects using the
factory.
key - the object that is used for finding the entry
public T removeEntry(T key)
KeyEntry
objects using the factory.
key - the element that is used for finding the element to remove
null if no element that is equal
to the given one is foundpublic boolean remove(Object o)
remove in interface Collection<T>remove in class AbstractCollection<T>public void clear()
clear in interface Collection<T>clear in class AbstractCollection<T>public int size()
size in interface Collection<T>size in class AbstractCollection<T>public Iterator<T> iterator()
iterator in interface Iterable<T>iterator in interface Collection<T>iterator in class AbstractCollection<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||