Package org.htmlunit.cyberneko.util
Class FastHashMap<K,V>
- java.lang.Object
-
- org.htmlunit.cyberneko.util.FastHashMap<K,V>
-
- Type Parameters:
K- the type of the keyV- the type of the value
- All Implemented Interfaces:
Serializable
public class FastHashMap<K,V> extends Object implements Serializable
Simple hash map implementation taken from here https://github.com/mikvor/hashmapTest/blob/master/src/main/java/map/objobj/ObjObjMap.java No concrete license specified at the source. The project is public domain. Not thread-safe! Null support was removed.- Since:
- 3.10.0
- Author:
- René Schwietzke
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FastHashMap()FastHashMap(int size, float fillFactor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intarraySize(int expected, float f)Returns the least power of two smaller than or equal to 230 and larger than or equal toMath.ceil( expected / f ).voidclear()Clears the map, reuses the data structure by clearing it out.Vget(K key)List<K>keys()static longnextPowerOfTwo(long x)Return the least power of two greater than or equal to the specified value.Vput(K key, V value)Vremove(K key)intsize()List<V>values()
-
-
-
Method Detail
-
size
public int size()
-
clear
public void clear()
Clears the map, reuses the data structure by clearing it out. It won't shrink the underlying array!
-
nextPowerOfTwo
public static long nextPowerOfTwo(long x)
Return the least power of two greater than or equal to the specified value.Note that this function will return 1 when the argument is 0.
- Parameters:
x- a long integer smaller than or equal to 262.- Returns:
- the least power of two greater than or equal to the specified value.
-
arraySize
public static int arraySize(int expected, float f)Returns the least power of two smaller than or equal to 230 and larger than or equal toMath.ceil( expected / f ).- Parameters:
expected- the expected number of elements in a hash table.f- the load factor.- Returns:
- the minimum possible size for a backing array.
- Throws:
IllegalArgumentException- if the necessary size is larger than 230.
-
-