org.apache.lucene.facet.collections

## Class IntHashSet

- java.lang.Object
- - org.apache.lucene.facet.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 and Description
`IntHashSet()` Constructs a map with default capacity.
`IntHashSet(int capacity)` Constructs a map with given capacity.

### Method Summary

Methods
`boolean` `add(int value)` Add a mapping int key -> int value.
`protected int` `calcBaseHashIndex(int key)` Calculating the baseHash index using the internal `hashFactor` .
`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.
`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 Objects
`int[]` `toArray(int[] a)` Translates the mapped pairs' values into an array of ints
`String` `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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### IntHashSet

    public IntHashSet()

Constructs a map with default capacity.

#### IntHashSet

    public IntHashSet(int capacity)

Constructs a map with given capacity. Capacity is adjusted to a native power of 2, with minimum of 16.

Parameters:
  `capacity` - minimum capacity for the map.

### Method Detail

#### calcBaseHashIndex

    protected int calcBaseHashIndex(int key)

Calculating the baseHash index using the internal `hashFactor` .

#### 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.

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.

#### 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.

Overrides:
  `toString` in class `Object`

#### toHashString

    public String toHashString()