Class IntHashSet
- java.lang.Object
-
- org.apache.lucene.util.collections.IntHashSet
-
public class IntHashSet extends Object
A Set or primitive int. Implemented as a HashMap of int->int. *- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description IntHashSet()
Constructs a map with default capacity.IntHashSet(int capacity)
Constructs a map with given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(int value)
Add a mapping int key -> int value.protected int
calcBaseHashIndex(int key)
Calculating the baseHash index using the internalhashFactor
.void
clear()
Empties the map.boolean
contains(int value)
Checks if a given key exists in the map.protected int
find(int key)
Find the actual index of a given key.protected void
grow()
Grows the map.boolean
isEmpty()
IntIterator
iterator()
Returns a new iterator for the mapped objects.void
printBaseHash()
Prints the baseHash array, used for debug purposes.boolean
remove(int value)
Remove a pair from the map, specified by it's key.int
size()
int[]
toArray()
Translates the mapped pairs' values into an array of Objectsint[]
toArray(int[] a)
Translates the mapped pairs' values into an array of intsString
toHashString()
String
toString()
I have no idea why would anyone call it - but for debug purposes.
Prints the entire map, including the index, key, object, next and prev.
-
-
-
Method Detail
-
calcBaseHashIndex
protected int calcBaseHashIndex(int key)
Calculating the baseHash index using the internalhashFactor
.- Parameters:
key
-
-
clear
public void clear()
Empties the map. Generates the "Empty" space list for later allocation.
-
contains
public boolean contains(int value)
Checks if a given key exists in the map.- Parameters:
value
- that is checked against the map data.- Returns:
- true if the key exists in the map. false otherwise.
-
find
protected int find(int key)
Find the actual index of a given key.- Parameters:
key
-- Returns:
- index of the key. zero if the key wasn't found.
-
grow
protected void grow()
Grows the map. Allocates a new map of double the capacity, and fast-insert the old key-value pairs.
-
isEmpty
public boolean isEmpty()
- Returns:
- true if the map is empty. false otherwise.
-
iterator
public IntIterator iterator()
Returns a new iterator for the mapped objects.
-
printBaseHash
public void printBaseHash()
Prints the baseHash array, used for debug purposes.
-
add
public boolean add(int value)
Add a mapping int key -> int value.If the key was already inside just updating the value it refers to as the given object.
Otherwise if the map is full, first
grow()
the map.- Parameters:
value
- integer which maps the given value- Returns:
- true always.
-
remove
public boolean remove(int value)
Remove a pair from the map, specified by it's key.- Parameters:
value
- specify the value to be removed- Returns:
- true if the map was changed (the key was found and removed). false otherwise.
-
size
public int size()
- Returns:
- number of pairs currently in the map
-
toArray
public int[] toArray()
Translates the mapped pairs' values into an array of Objects- Returns:
- an object array of all the values currently in the map.
-
toArray
public int[] toArray(int[] a)
Translates the mapped pairs' values into an array of ints- Parameters:
a
- the array into which the elements of the map are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- Returns:
- an array containing the values stored in the map
-
toString
public String toString()
I have no idea why would anyone call it - but for debug purposes.
Prints the entire map, including the index, key, object, next and prev.
-
toHashString
public String toHashString()
-
-