|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.collections.IntToDoubleMap
public class IntToDoubleMap
An Array-based hashtable which maps primitive int to a primitive double.
The hashtable is constracted with a given capacity, or 16 as a default. In
case there's not enough room for new pairs, the hashtable grows.
Capacity is adjusted to a power of 2, and there are 2 * capacity entries for
the hash.
The pre allocated arrays (for keys, values) are at length of capacity + 1,
when index 0 is used as 'Ground' or 'NULL'.
The arrays are allocated ahead of hash operations, and form an 'empty space'
list, to which the key,value pair is allocated.
Field Summary | |
---|---|
static double |
GROUND
|
Constructor Summary | |
---|---|
IntToDoubleMap()
Constructs a map with default capacity. |
|
IntToDoubleMap(int capacity)
Constructs a map with given capacity. |
Method Summary | |
---|---|
protected int |
calcBaseHashIndex(int key)
Calculating the baseHash index using the internal hashFactor
. |
void |
clear()
Empties the map. |
boolean |
containsKey(int key)
Checks if a given key exists in the map. |
boolean |
containsValue(double value)
Checks if the given value exists in the map. This method iterates over the collection, trying to find an equal object. |
boolean |
equals(Object o)
|
protected int |
find(int key)
Find the actual index of a given key. |
double |
get(int key)
Returns the value mapped with the given key. |
protected void |
grow()
Grows the map. |
int |
hashCode()
|
boolean |
isEmpty()
|
DoubleIterator |
iterator()
Returns a new iterator for the mapped double values. |
IntIterator |
keyIterator()
Returns an iterator on the map keys. |
double |
put(int key,
double v)
Inserts the <key,value> pair into the map. |
double |
remove(int key)
Removes a <key,value> pair from the map and returns the mapped value, or Double.NaN if the none existed. |
int |
size()
|
double[] |
toArray()
Translates the mapped pairs' values into an array of Objects |
double[] |
toArray(double[] a)
Translates the mapped pairs' values into an array of T |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final double GROUND
Constructor Detail |
---|
public IntToDoubleMap()
public IntToDoubleMap(int capacity)
capacity
- minimum capacity for the map.Method Detail |
---|
protected int calcBaseHashIndex(int key)
hashFactor
.
key
- public void clear()
public boolean containsKey(int key)
key
- that is checked against the map data.
public boolean containsValue(double value)
value
- double value that is checked against the map data.
protected int find(int key)
key
-
public double get(int key)
key
- int who's mapped object we're interested in.
protected void grow()
public boolean isEmpty()
public DoubleIterator iterator()
public IntIterator keyIterator()
public double put(int key, double v)
Double.NaN
if the key didn't exist.public double remove(int key)
Double.NaN
if the none existed.
key
- used to find the value to remove
Double.NaN
if none existed.public int size()
public double[] toArray()
public double[] toArray(double[] a)
a
- the array into which the elements of the list are to be
stored. If it is big enough use whatever space we need,
setting the one after the true data as Double.NaN
.
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |