Top Description Inners Fields Constructors Methods
com.carrotsearch.hppc

public Class LongDoubleHashMap

extends Object
implements LongDoubleMap, Preallocable, Cloneable, Accountable
Class Inheritance
All Implemented Interfaces
com.carrotsearch.hppc.Accountable, java.lang.Cloneable, com.carrotsearch.hppc.Preallocable, com.carrotsearch.hppc.LongDoubleMap, com.carrotsearch.hppc.LongDoubleAssociativeContainer, java.lang.Iterable
Annotations
@Generated:KTypeVTypeHashMap.java
date:2024-06-04T15:20:17+0200
Static Imports
com.carrotsearch.hppc.Containers.*, com.carrotsearch.hppc.HashContainers.*

A hash map of long to double, implemented using open addressing with linear probing for collision resolution.
See Also
HPPC interfaces diagram

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
LongDoubleHashMap.EntryIterator

An iterator implementation for iterator.

public class
LongDoubleHashMap.KeysContainer

A view of the keys inside this hash map.

private class
LongDoubleHashMap.KeysIterator

An iterator over the set of assigned keys.

private class
LongDoubleHashMap.ValuesContainer

A view over the set of values of this map.

private class
LongDoubleHashMap.ValuesIterator

An iterator over the set of assigned values.

Field Summary

Modifier and TypeField and Description
protected int
assigned

The number of stored keys (assigned key slots), excluding the special "empty" key, if any (use size() instead).

protected boolean
hasEmptyKey

Special treatment for the "empty slot" key marker.

protected int
iterationSeed

Seed used to ensure the hash iteration order is different from an iteration to another.

public long[]
keys

The array holding keys.

protected double
loadFactor

The load factor for keys.

protected int
mask

Mask for slot scans in keys.

protected int
resizeAt

Expand (rehash) keys when assigned hits this value.

public double[]
values

The array holding values.

Constructor Summary

AccessConstructor and Description
public
LongDoubleHashMap()

New instance with sane defaults.

public
LongDoubleHashMap(int
The expected number of elements guaranteed not to cause buffer expansion (inclusive).
expectedElements
)

New instance with sane defaults.

public
LongDoubleHashMap(int
The expected number of elements guaranteed not to cause a rehash (inclusive).
expectedElements
,
double
The load factor for internal buffers. Insane load factors (zero, full capacity) are rejected by verifyLoadFactor(double).
loadFactor
)

New instance with the provided defaults.

public
LongDoubleHashMap(LongDoubleAssociativeContainer container)

Create a hash map from all key-value pairs of another container.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

Returns the current value associated with key (after changes).
addTo
(long
The key of the value to adjust.
key
,
double
The value to put or add to the existing value if key exists.
incrementValue
)

Implements com.carrotsearch.hppc.LongDoubleMap.addTo.

Adds incrementValue to any existing value for the given key or inserts incrementValue if key did not previously exist.

protected void
allocateBuffers(int arraySize)

Allocate new internal buffers.

protected void
allocateThenInsertThenRehash(int slot, long pendingKey, double pendingValue)

This method is invoked when there is a new key/ value pair to be inserted into the buffers but there is not enough empty slots to do so.

public void
clear()

Implements com.carrotsearch.hppc.LongDoubleMap.clear.

Clear all keys and values in the container.

public LongDoubleHashMap
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public boolean
containsKey(long key)

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.containsKey.

Returns true if this container has an association to a value for the given key.

public void
ensureCapacity(int
The total number of keys, inclusive.
expectedElements
)

Implements com.carrotsearch.hppc.Preallocable.ensureCapacity.

Ensure this container can hold at least the given number of keys (entries) without resizing its buffers.

protected boolean
equalElements(LongDoubleHashMap other)

Return true if all keys of some other container exist in this container.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Implements com.carrotsearch.hppc.LongDoubleMap.equals.

Compares the specified object with this set for equality.

public <T extends LongDoubleProcedure> T
forEach(T procedure)

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.forEach, com.carrotsearch.hppc.LongDoubleAssociativeContainer.forEach.

Applies a given procedure to all keys-value pairs in this container.

public <T extends LongDoublePredicate> T
forEach(T predicate)

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.forEach, com.carrotsearch.hppc.LongDoubleAssociativeContainer.forEach.

Applies a given procedure to all keys-value pairs in this container.

public static LongDoubleHashMap
from(long[] keys, double[] values)

Creates a hash map from two index-aligned arrays of key-value pairs.

public double
public double
getOrDefault(long key, double defaultValue)

Implements com.carrotsearch.hppc.LongDoubleMap.getOrDefault.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements com.carrotsearch.hppc.LongDoubleMap.hashCode.

Returns a hash code value for this object.

protected int
hashKey(long key)

Returns a hash code for the given key.

public boolean
indexExists(int
The index of a given key, as returned from indexOf.
index
)

Implements com.carrotsearch.hppc.LongDoubleMap.indexExists.

public double
indexGet(int
The index of an existing key.
index
)

Implements com.carrotsearch.hppc.LongDoubleMap.indexGet.

Returns the value associated with an existing key.

public void
indexInsert(int
The index of a previously non-existing key, as returned from indexOf.
index
,
long key, double value)

Implements com.carrotsearch.hppc.LongDoubleMap.indexInsert.

Inserts a key-value pair for a key that is not present in the map.

public int
indexOf(long
The key to locate in the map.
key
)

Implements com.carrotsearch.hppc.LongDoubleMap.indexOf.

Returns a logical "index" of a given key that can be used to speed up follow-up value setters or getters in certain scenarios (conditional logic).

public double
indexRemove(int
The index of the key to remove, as returned from indexOf.
index
)

Implements com.carrotsearch.hppc.LongDoubleMap.indexRemove.

Removes a key-value pair at an index previously acquired from indexOf.

public double
indexReplace(int
The index of an existing key.
index
,
double newValue)

Implements com.carrotsearch.hppc.LongDoubleMap.indexReplace.

Replaces the value associated with an existing key and returns any previous value stored for that key.

public boolean
public Iterator<LongDoubleCursor>
iterator()

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.iterator.

Returns a cursor over the entries (key-value pairs) in this map.

public LongDoubleHashMap.KeysContainer
keys()

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.keys.

Returns a specialized view of the keys of this associated container.

protected int
nextIterationSeed()

Provides the next iteration seed used to build the iteration starting slot and offset increment.

public double
put(long key, double value)

Implements com.carrotsearch.hppc.LongDoubleMap.put.

Place a given key and value in the container.

public int
putAll(LongDoubleAssociativeContainer container)

Implements com.carrotsearch.hppc.LongDoubleMap.putAll.

Puts all keys from another container to this map, replacing the values of existing keys, if such keys are present.

public int
putAll(Iterable<? extends LongDoubleCursor> iterable)

Implements com.carrotsearch.hppc.LongDoubleMap.putAll.

Puts all key/value pairs from a given iterable into this map.

public double

Returns:

Returns the current value associated with key (after changes).
putOrAdd
(long
The key of the value to adjust.
key
,
double
The value to put if key does not exist.
putValue
,
double
The value to add to the existing value if key exists.
incrementValue
)

Implements com.carrotsearch.hppc.LongDoubleMap.putOrAdd.

If key exists, putValue is inserted into the map, otherwise any existing value is incremented by additionValue.

public long
public long
ramBytesUsed()

Implements com.carrotsearch.hppc.Accountable.ramBytesUsed.

Bytes that is actually been used

protected void
rehash(long[] fromKeys, double[] fromValues)

Rehash from old buffers to new buffers.

public void
release()

Implements com.carrotsearch.hppc.LongDoubleMap.release.

Removes all elements from the collection and additionally releases any internal buffers.

public double
remove(long key)

Implements com.carrotsearch.hppc.LongDoubleMap.remove.

Remove all values at the given key.

public int
removeAll(LongContainer other)

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.removeAll.

Removes all keys (and associated values) present in a given container.

public int
removeAll(LongDoublePredicate predicate)

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.removeAll.

Removes all keys (and associated values) for which the predicate returns true.

public int
removeAll(LongPredicate predicate)

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.removeAll.

Removes all keys (and associated values) for which the predicate returns true.

protected void
shiftConflictingKeys(int gapSlot)

Shift all the slot-conflicting keys and values allocated to (and including) slot.

public int
public String
toString()

Overrides java.lang.Object.toString.

Convert the contents of this map to a human-friendly string.

public DoubleCollection

Returns:

Returns a container with all values stored in this map.
values
()

Implements com.carrotsearch.hppc.LongDoubleAssociativeContainer.values.

Returns a container view of all values present in this container.

protected double
verifyLoadFactor(double loadFactor)

Validate load factor range and return it.

public String
visualizeKeyDistribution(int
The number of characters to "squeeze" the entire buffer into.
characters
)

Implements com.carrotsearch.hppc.LongDoubleMap.visualizeKeyDistribution.

Visually depict the distribution of keys.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait