|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.osgi.framework.util.KeyedHashSet
public class KeyedHashSet
A set data structure which only accepts KeyedElement
objects as elements of the set.
Unlike typical set implementations this set requires each element to provide its own key. This helps
reduce the overhead of storing the keys of each individual element
This class in not thread safe, clients must ensure synchronization when modifying an object of this type.
Field Summary | |
---|---|
static int |
MINIMUM_SIZE
|
Constructor Summary | |
---|---|
KeyedHashSet()
Constructs an KeyedHashSet which allows elements to be replaced and with the minimum initial capacity. |
|
KeyedHashSet(boolean replace)
Constructs an KeyedHashSet with the minimum initial capacity. |
|
KeyedHashSet(int capacity)
Constructs an KeyedHashSet which allows elements to be replaced. |
|
KeyedHashSet(int capacity,
boolean replace)
Constructs an KeyedHashSet |
|
KeyedHashSet(KeyedHashSet original)
Constructs a new KeyedHashSet and copies to specified KeyedHashSet's contents to the new KeyedHashSet. |
Method Summary | |
---|---|
boolean |
add(KeyedElement element)
Adds an element to this set. |
void |
addAll(KeyedElement[] toAdd)
Adds the specified list of elements to this set. |
void |
clear()
Clears all elements from this set |
boolean |
contains(KeyedElement element)
Returns true if the specified element exists in this set. |
boolean |
containsKey(java.lang.Object key)
Returns true if an element with the specified key exists in this set. |
int |
countCollisions()
Returns the number of collisions this set currently has |
KeyedElement[] |
elements()
Returns all elements that exist in this set |
java.lang.Object[] |
elements(java.lang.Object[] result)
Copies all elements that exist in this set into the specified array. |
protected void |
expand()
The array isn't large enough so double its size and rehash all its current values. |
KeyedElement |
get(KeyedElement otherElement)
Returns the element which compares to the specified element, or null if not found. |
KeyedElement |
getByKey(java.lang.Object key)
Returns the element with the specified key, or null if not found. |
boolean |
isEmpty()
Returns true if this set is empty |
java.util.Iterator |
iterator()
Returns an iterator of elements in this set |
protected void |
rehashTo(int anIndex)
The element at the given index has been removed so move elements to keep the set properly hashed. |
boolean |
remove(KeyedElement toRemove)
Removes the element which compares to the specified element |
void |
removeAll(KeyedElement[] toRemove)
Removes all of the specified elements from this set |
boolean |
removeByKey(java.lang.Object key)
Removes the element with the specified key |
int |
size()
Returns the number of elements in this set |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MINIMUM_SIZE
Constructor Detail |
---|
public KeyedHashSet()
public KeyedHashSet(boolean replace)
replace
- true if this set allows elements to be replacedpublic KeyedHashSet(int capacity)
capacity
- the initial capacity of this setpublic KeyedHashSet(int capacity, boolean replace)
capacity
- the initial capacity of this setreplace
- true if this set allows elements to be replacedpublic KeyedHashSet(KeyedHashSet original)
original
- the KeyedHashSet to copyMethod Detail |
---|
public boolean add(KeyedElement element)
public void addAll(KeyedElement[] toAdd)
toAdd
- the list of elements to add to this set.public boolean contains(KeyedElement element)
element
- the requested element
public boolean containsKey(java.lang.Object key)
key
- the key of the requested element
public KeyedElement[] elements()
public java.lang.Object[] elements(java.lang.Object[] result)
result
- the array to copy the existing elements into.
java.lang.ArrayIndexOutOfBoundsException
- if the specified array is to small.protected void expand()
public KeyedElement getByKey(java.lang.Object key)
key
- the requested element's key
public KeyedElement get(KeyedElement otherElement)
otherElement
- the requested element
KeyedElement.compare(KeyedElement)
public boolean isEmpty()
protected void rehashTo(int anIndex)
anIndex
- the index that has been removedpublic boolean removeByKey(java.lang.Object key)
key
- the requested element's key
public boolean remove(KeyedElement toRemove)
toRemove
- the requested element to remove
public void removeAll(KeyedElement[] toRemove)
toRemove
- the requested elements to removepublic int size()
public java.lang.String toString()
toString
in class java.lang.Object
public int countCollisions()
public java.util.Iterator iterator()
public void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |