de.cm.osm2po.sd.primitives
Class IntTHashMap<T>

java.lang.Object
  extended by de.cm.osm2po.sd.primitives.IntTHashMap<T>
Type Parameters:
T - Generic Type.
All Implemented Interfaces:
java.lang.Iterable<T>

public class IntTHashMap<T>
extends java.lang.Object
implements java.lang.Iterable<T>

This is a Hashmap for Java-Objects as value with a primitive int as key.

Important:
rehash() will not be triggered automatically. Statistics can be examined by getHashPopulation(), getHashSize(), getSize() and getMaxCollisions().

Author:
(c) 2013/2014 - Carsten Moeller - info@osm2po

Constructor Summary
IntTHashMap(int capacity)
           
 
Method Summary
 void clear()
           
 boolean contains(int key)
           
 T get(int key)
          Returns a value for a key.
 int getHashPopulation()
           
 int getHashSize()
           
 int getMaxCollisions()
           
 int getSize()
           
 java.util.Iterator<T> iterator()
           
 void put(int key, T value)
          Adds a new key/value.
 void rehash()
          Increases the Hash by factor 2.
 T remove(int key)
          Removes an element.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntTHashMap

public IntTHashMap(int capacity)
Parameters:
capacity - Initially expected number of elements.

Important:
The capacity affects the internally used HashSize (by 2 at n^2 -1 elements) and (by 4 at n^2.
Method Detail

clear

public void clear()

getSize

public int getSize()
Returns:
Number of elements.

getHashSize

public int getHashSize()
Returns:
Size of currently used Hash.

getMaxCollisions

public int getMaxCollisions()
Returns:
Length of longest collision list after put(int, Object) or rehash(). For performance reasons not after remove(int).

getHashPopulation

public int getHashPopulation()
Returns:
Number of used slots in HashArray.

put

public void put(int key,
                T value)
Adds a new key/value.

Parameters:
key - int
value - Object T

remove

public T remove(int key)
Removes an element.

Parameters:
key - int
Returns:
Object T removed value.

contains

public boolean contains(int key)
Parameters:
key - int
Returns:
boolean map contains key.

get

public T get(int key)
Returns a value for a key.

Parameters:
key - int
Returns:
Object T value or null if not found

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

rehash

public void rehash()
Increases the Hash by factor 2.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

osm2po-sd-5.0.0 (c) December 24 2014 Carsten Moeller - info@osm2po.de