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
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.keys()static longnextPowerOfTwo(long x) Return the least power of two greater than or equal to the specified value.intsize()values()
-
Constructor Details
-
FastHashMap
public FastHashMap() -
FastHashMap
public FastHashMap(int size, float fillFactor)
-
-
Method Details
-
get
-
put
-
remove
-
size
public int size() -
keys
- Returns:
- a list of all keys
-
values
- Returns:
- a list of all values
-
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.
-