|
||||||||||
| 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<E>
net.ontopia.utils.CompactHashSet<E>
public class CompactHashSet<E>
INTERNAL: Implements the Set interface more compactly than java.util.HashSet by using a closed hashtable.
| Field Summary | |
|---|---|
protected static java.lang.Object |
deletedObject
When an object is deleted this object is put into the hashtable in its place, so that other objects with the same key (collisions) further down the hashtable are not lost after we delete an object in the collision chain. |
protected int |
elements
|
protected int |
freecells
This is the number of empty (null) cells. |
protected static int |
INITIAL_SIZE
|
protected static double |
LOAD_FACTOR
|
protected int |
modCount
|
protected static java.lang.Object |
nullObject
This object is used to represent null, should clients add that to the set. |
protected E[] |
objects
|
| Constructor Summary | |
|---|---|
CompactHashSet()
Constructs a new, empty set. |
|
CompactHashSet(java.util.Collection<E> c)
Constructs a new set containing the elements in the specified collection. |
|
CompactHashSet(int size)
Constructs a new, empty set. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(java.lang.Object o)
Adds the specified element to this set if it is not already present. |
|
void |
clear()
Removes all of the elements from this set. |
|
boolean |
contains(java.lang.Object o)
Returns true if this set contains the specified element. |
|
void |
dump()
INTERNAL: Used for debugging only. |
|
boolean |
isEmpty()
Returns true if this set contains no elements. |
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this set. |
|
protected void |
rehash()
INTERNAL: Figures out correct size for rehashed set, then does the rehash. |
|
protected void |
rehash(int newCapacity)
INTERNAL: Rehashes the hashset to a bigger size. |
|
boolean |
remove(java.lang.Object o)
Removes the specified element from the set. |
|
int |
size()
Returns the number of elements in this set (its cardinality). |
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
addAll, containsAll, retainAll |
| Field Detail |
|---|
protected static final int INITIAL_SIZE
protected static final double LOAD_FACTOR
protected static final java.lang.Object nullObject
protected static final java.lang.Object deletedObject
protected int elements
protected int freecells
protected E[] objects
protected int modCount
| Constructor Detail |
|---|
public CompactHashSet()
public CompactHashSet(int size)
public CompactHashSet(java.util.Collection<E> c)
c - the collection whose elements are to be placed into this set.| Method Detail |
|---|
public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>iterator in interface java.util.Collection<E>iterator in interface java.util.Set<E>iterator in class java.util.AbstractCollection<E>ConcurrentModificationExceptionpublic int size()
size in interface java.util.Collection<E>size in interface java.util.Set<E>size in class java.util.AbstractCollection<E>public boolean isEmpty()
isEmpty in interface java.util.Collection<E>isEmpty in interface java.util.Set<E>isEmpty in class java.util.AbstractCollection<E>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<E>contains in interface java.util.Set<E>contains in class java.util.AbstractCollection<E>o - element whose presence in this set is to be tested.
public boolean add(java.lang.Object o)
add in interface java.util.Collection<E>add in interface java.util.Set<E>add in class java.util.AbstractCollection<E>o - element to be added to this set.
public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<E>remove in interface java.util.Set<E>remove in class java.util.AbstractCollection<E>public void clear()
clear in interface java.util.Collection<E>clear in interface java.util.Set<E>clear in class java.util.AbstractCollection<E>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>toArray in interface java.util.Set<E>toArray in class java.util.AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface java.util.Collection<E>toArray in interface java.util.Set<E>toArray in class java.util.AbstractCollection<E>public void dump()
protected void rehash()
protected void rehash(int newCapacity)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||