org.apache.felix.resolver.util

## Class OpenHashMap<K,V>

- java.lang.Object
- - org.apache.felix.resolver.util.OpenHashMap<K,V>

All Implemented Interfaces:
  Serializable, Cloneable, Map<K,V>, SortedMap<K,V>

Direct Known Subclasses:
  OpenHashMapList, OpenHashMapSet

    public class OpenHashMap<K,V>
    extends Object
    implements Serializable, Cloneable, SortedMap<K,V>

Based on fastutil Object2ObjectLinkedOpenHashMap

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `OpenHashMap.AbstractObjectCollection<K>`
`static class` `OpenHashMap.AbstractObjectSet<K>`

### Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K,V>`

### Field Summary

Fields
`protected boolean` `containsNullKey`
`protected V` `defRetValue`
`protected SortedSet<Map.Entry<K,V>>` `entries`
`protected float` `f`
`protected Iterable<Map.Entry<K,V>>` `fast`
`protected int` `first`
`protected Object[]` `key`
`protected SortedSet<K>` `keys`
`protected int` `last`
`protected long[]` `link`
`protected int` `mask`
`protected int` `maxFill`
`protected int` `n`
`protected int` `size`
`protected Object[]` `value`
`protected Collection<V>` `values`

### Constructor Summary

Constructors
Constructor and Description
`OpenHashMap()`
`OpenHashMap(int expected)`
`OpenHashMap(int expected, float f)`
`OpenHashMap(K[] k, V[] v)`
`OpenHashMap(K[] k, V[] v, float f)`
`OpenHashMap(Map<? extends K,? extends V> m)`
`OpenHashMap(Map<? extends K,? extends V> m, float f)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clear()`
`OpenHashMap<K,V>` `clone()`
`Comparator<? super K>` `comparator()`
`protected V` `compute(K k)`
`boolean` `containsKey(Object k)`
`boolean` `containsValue(Object v)`
`V` `defaultReturnValue()`
`void` `defaultReturnValue(V rv)`
`SortedSet<Map.Entry<K,V>>` `entrySet()`
`boolean` `equals(Object o)`
`Iterable<Map.Entry<K,V>>` `fast()`
`K` `firstKey()`
`protected void` `fixPointers(int i)`
`protected void` `fixPointers(int s, int d)`
`V` `get(Object k)`
`V` `getOrCompute(K k)`
`int` `hashCode()`
`SortedMap<K,V>` `headMap(K to)`
`boolean` `isEmpty()`
`SortedSet<K>` `keySet()`
`K` `lastKey()`
`V` `put(K k, V v)`
`void` `putAll(Map<? extends K,? extends V> m)`
`protected void` `rehash(int newN)` Rehashes the map.
`V` `remove(Object k)`
`V` `removeFirst()`
`V` `removeLast()`
`protected void` `shiftKeys(int pos)`
`int` `size()`
`SortedMap<K,V>` `subMap(K from, K to)`
`SortedMap<K,V>` `tailMap(K from)`
`String` `toString()`
`boolean` `trim()` Rehashes the map, making the table as small as possible.
`boolean` `trim(int n)` Rehashes this map if the table is too large.
`Collection<V>` `values()`

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

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Map

`compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll`

### Field Detail

#### key

    protected transient Object[] key

#### value

    protected transient Object[] value

#### mask

    protected transient int mask

#### containsNullKey

    protected transient boolean containsNullKey

#### first

    protected transient int first

#### last

    protected transient int last

#### link

    protected transient long[] link

#### n

    protected transient int n

#### maxFill

    protected transient int maxFill

#### size

    protected int size

#### f

    protected final float f

#### defRetValue

    protected V defRetValue

#### fast

    protected transient Iterable<Map.Entry<K,V>> fast

#### entries

    protected transient SortedSet<Map.Entry<K,V>> entries

#### keys

    protected transient SortedSet<K> keys

#### values

    protected transient Collection<V> values

### Constructor Detail

#### OpenHashMap

    public OpenHashMap(int expected,
                       float f)

#### OpenHashMap

    public OpenHashMap(int expected)

#### OpenHashMap

    public OpenHashMap()

#### OpenHashMap

    public OpenHashMap(Map<? extends K,? extends V> m,
                       float f)

#### OpenHashMap

    public OpenHashMap(Map<? extends K,? extends V> m)

#### OpenHashMap

    public OpenHashMap(K[] k,
                       V[] v,
                       float f)

#### OpenHashMap

    public OpenHashMap(K[] k,
                       V[] v)

### Method Detail

#### defaultReturnValue

    public void defaultReturnValue(V rv)

#### defaultReturnValue

    public V defaultReturnValue()

#### equals

    public boolean equals(Object o)

Specified by:
  `equals` in interface `Map<K,V>`
Overrides:
  `equals` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### putAll

    public void putAll(Map<? extends K,? extends V> m)

Specified by:
  `putAll` in interface `Map<K,V>`

#### put

    public V put(K k,
                 V v)

Specified by:
  `put` in interface `Map<K,V>`

#### getOrCompute

    public V getOrCompute(K k)

#### compute

    protected V compute(K k)

#### shiftKeys

    protected final void shiftKeys(int pos)

#### remove

    public V remove(Object k)

Specified by:
  `remove` in interface `Map<K,V>`

#### removeFirst

    public V removeFirst()

#### removeLast

    public V removeLast()

#### get

    public V get(Object k)

Specified by:
  `get` in interface `Map<K,V>`

#### containsKey

    public boolean containsKey(Object k)

Specified by:
  `containsKey` in interface `Map<K,V>`

#### containsValue

    public boolean containsValue(Object v)

Specified by:
  `containsValue` in interface `Map<K,V>`

#### clear

    public void clear()

Specified by:
  `clear` in interface `Map<K,V>`

#### size

    public int size()

Specified by:
  `size` in interface `Map<K,V>`

#### isEmpty

    public boolean isEmpty()

Specified by:
  `isEmpty` in interface `Map<K,V>`

#### fixPointers

    protected void fixPointers(int i)

#### fixPointers

    protected void fixPointers(int s,
                               int d)

#### firstKey

    public K firstKey()

Specified by:
  `firstKey` in interface `SortedMap<K,V>`

#### lastKey

    public K lastKey()

Specified by:
  `lastKey` in interface `SortedMap<K,V>`

#### comparator

    public Comparator<? super K> comparator()

Specified by:
  `comparator` in interface `SortedMap<K,V>`

#### tailMap

    public SortedMap<K,V> tailMap(K from)

Specified by:
  `tailMap` in interface `SortedMap<K,V>`

#### headMap

    public SortedMap<K,V> headMap(K to)

Specified by:
  `headMap` in interface `SortedMap<K,V>`

#### subMap

    public SortedMap<K,V> subMap(K from,
                                 K to)

Specified by:
  `subMap` in interface `SortedMap<K,V>`

#### fast

    public Iterable<Map.Entry<K,V>> fast()

#### entrySet

    public SortedSet<Map.Entry<K,V>> entrySet()

Specified by:
  `entrySet` in interface `Map<K,V>`
Specified by:
  `entrySet` in interface `SortedMap<K,V>`

#### keySet

    public SortedSet<K> keySet()

Specified by:
  `keySet` in interface `Map<K,V>`
Specified by:
  `keySet` in interface `SortedMap<K,V>`

#### values

    public Collection<V> values()

Specified by:
  `values` in interface `Map<K,V>`
Specified by:
  `values` in interface `SortedMap<K,V>`

#### trim

    public boolean trim()

Rehashes the map, making the table as small as possible.

This method rehashes the table to the smallest size satisfying the load factor. It can be used when the set will not be changed anymore, so to optimize access speed and size.

If the table size is already the minimum possible, this method does nothing.

Returns:
  true if there was enough memory to trim the map.
See Also:
  `trim(int)`

#### trim

    public boolean trim(int n)

Rehashes this map if the table is too large.

Let N be the smallest table size that can hold `max(n,`size()`)` entries, still satisfying the load factor. If the current table size is smaller than or equal to N, this method does nothing. Otherwise, it rehashes this map in a table of size N.

This method is useful when reusing maps. Clearing a map leaves the table size untouched. If you are reusing a map many times, you can call this method with a typical size to avoid keeping around a very large table just because of a few large transient maps.

Parameters:
  `n` - the threshold for the trimming.
Returns:
  true if there was enough memory to trim the map.
See Also:
  `trim()`

#### rehash

    protected void rehash(int newN)

Rehashes the map.

This method implements the basic rehashing strategy, and may be overriden by subclasses implementing different rehashing strategies (e.g., disk-based rehashing). However, you should not override this method unless you understand the internal workings of this class.

Parameters:
  `newN` - the new size

#### clone

    public OpenHashMap<K,V> clone()

Overrides:
  `clone` in class `Object`

#### hashCode

    public int hashCode()

Specified by:
  `hashCode` in interface `Map<K,V>`
Overrides:
  `hashCode` in class `Object`