|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.PersistentObject
org.apache.mahout.math.set.AbstractSet
org.apache.mahout.math.set.OpenHashSet<T>
public class OpenHashSet<T>
Open hashing alternative to java.util.HashSet.
Field Summary | |
---|---|
protected static byte |
FREE
|
protected static byte |
FULL
|
protected static char |
NO_KEY_VALUE
|
protected static byte |
REMOVED
|
Fields inherited from class org.apache.mahout.math.set.AbstractSet |
---|
DEFAULT_CAPACITY, DEFAULT_MAX_LOAD_FACTOR, DEFAULT_MIN_LOAD_FACTOR, distinct, highWaterMark, lowWaterMark, maxLoadFactor, minLoadFactor |
Constructor Summary | |
---|---|
OpenHashSet()
Constructs an empty map with default capacity and default load factors. |
|
OpenHashSet(int initialCapacity)
Constructs an empty map with the specified initial capacity and default load factors. |
|
OpenHashSet(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Constructs an empty map with the specified initial capacity and the specified minimum and maximum load factor. |
Method Summary | ||
---|---|---|
boolean |
add(Object key)
|
|
boolean |
addAll(Collection<? extends T> c)
|
|
void |
clear()
Removes all values associations from the receiver. |
|
Object |
clone()
Returns a deep copy of the receiver. |
|
boolean |
contains(Object key)
Returns true if the receiver contains the specified key. |
|
boolean |
containsAll(Collection<?> c)
|
|
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of associations without needing to allocate new internal memory. |
|
boolean |
equals(Object obj)
OpenHashSet instances are only equal to other OpenHashSet instances, not to any other collection. |
|
boolean |
forEachKey(ObjectProcedure<T> procedure)
Applies a procedure to each key of the receiver, if any. |
|
int |
hashCode()
|
|
protected int |
indexOfInsertion(T key)
|
|
protected int |
indexOfKey(T key)
|
|
boolean |
isEmpty()
Returns true if the receiver contains no (key,value) associations. |
|
Iterator<T> |
iterator()
Implement the standard Java Collections iterator. |
|
List<T> |
keys()
|
|
void |
keys(List<T> list)
Fills all keys contained in the receiver into the specified list. |
|
protected void |
rehash(int newCapacity)
Rehashes the contents of the receiver into a new table with a smaller or larger capacity. |
|
boolean |
remove(Object key)
Removes the given key with its associated element from the receiver, if present. |
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
protected void |
setUp(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Initializes the receiver. |
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
void |
trimToSize()
Trims the capacity of the receiver to be the receiver's current size. |
Methods inherited from class org.apache.mahout.math.set.AbstractSet |
---|
chooseGrowCapacity, chooseHighWaterMark, chooseLowWaterMark, chooseMeanCapacity, chooseShrinkCapacity, equalsMindTheNull, nextPrime, size |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
size |
Field Detail |
---|
protected static final byte FREE
protected static final byte FULL
protected static final byte REMOVED
protected static final char NO_KEY_VALUE
Constructor Detail |
---|
public OpenHashSet()
public OpenHashSet(int initialCapacity)
initialCapacity
- the initial capacity of the map.
IllegalArgumentException
- if the initial capacity is less than zero.public OpenHashSet(int initialCapacity, double minLoadFactor, double maxLoadFactor)
initialCapacity
- the initial capacity.minLoadFactor
- the minimum load factor.maxLoadFactor
- the maximum load factor.
IllegalArgumentException
- if initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) ||
(maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >=
maxLoadFactor).Method Detail |
---|
public void clear()
clear
in interface Collection<T>
clear
in interface Set<T>
clear
in class AbstractSet
public Object clone()
clone
in class PersistentObject
public boolean contains(Object key)
contains
in interface Collection<T>
contains
in interface Set<T>
public void ensureCapacity(int minCapacity)
This method never need be called; it is for performance tuning only. Calling this method before add()ing a large number of associations boosts performance, because the receiver will grow only once instead of potentially many times and hash collisions get less probable.
ensureCapacity
in class AbstractSet
minCapacity
- the desired minimum capacity.public boolean forEachKey(ObjectProcedure<T> procedure)
procedure
- the procedure to be applied. Stops iteration if the procedure returns false, otherwise
continues.
protected int indexOfInsertion(T key)
key
- the key to be added to the receiver.
protected int indexOfKey(T key)
key
- the key to be searched in the receiver.
public void keys(List<T> list)
list
- the list to be filled, can have any size.public boolean add(Object key)
add
in interface Collection<T>
add
in interface Set<T>
protected void rehash(int newCapacity)
public boolean remove(Object key)
remove
in interface Collection<T>
remove
in interface Set<T>
key
- the key to be removed from the receiver.
protected void setUp(int initialCapacity, double minLoadFactor, double maxLoadFactor)
setUp
in class AbstractSet
initialCapacity
- the initial capacity of the receiver.minLoadFactor
- the minLoadFactor of the receiver.maxLoadFactor
- the maxLoadFactor of the receiver.
IllegalArgumentException
- if initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) ||
(maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >=
maxLoadFactor).public void trimToSize()
trimToSize
in class AbstractSet
public boolean isEmpty()
AbstractSet
isEmpty
in interface Collection<T>
isEmpty
in interface Set<T>
isEmpty
in class AbstractSet
public boolean equals(Object obj)
equals
in interface Collection<T>
equals
in interface Set<T>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<T>
hashCode
in interface Set<T>
hashCode
in class Object
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
iterator
in interface Set<T>
public Object[] toArray()
toArray
in interface Collection<T>
toArray
in interface Set<T>
public boolean addAll(Collection<? extends T> c)
addAll
in interface Collection<T>
addAll
in interface Set<T>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
containsAll
in interface Set<T>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<T>
removeAll
in interface Set<T>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<T>
retainAll
in interface Set<T>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<T>
toArray
in interface Set<T>
public List<T> keys()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |