Jacson

de.spieleck.util
Class IntMap

java.lang.Object
  extended by de.spieleck.util.IntMap

public class IntMap
extends java.lang.Object

The IntMap provides a simple hashmap from keys to integers. The API is simplified of the HashMap/Hashtable collection API. Additionally there are call to do simple arithmetic with entries in the map.

The convenience of IntMap is avoiding all wrapping of integers.

Note: This class is completely unsynchronized for speed!


Field Summary
protected  java.lang.Object[] keys
           
protected  int limit
           
protected  int mask
           
static int NULL
          Encoding of a null entry.
protected  int nullValue
           
protected  int size
           
protected  int[] values
           
 
Constructor Summary
IntMap()
          Create a new IntMap.
IntMap(int size)
           
IntMap(int size, int nullValue)
           
 
Method Summary
 int add(java.lang.Object key, int off)
          Optimized operations.
 void clear()
          Clear the hashmap.
 int dec(java.lang.Object key)
          Optimized operations.
protected  int firstIndex(java.lang.Object key)
          This only works with binary indizes
 int get(java.lang.Object key)
          Get an Element
 int getElement(java.lang.Object key)
          Get an Element
 int getNullValue()
           
protected  void grow()
          Expands the table
 int inc(java.lang.Object key)
          Optimized operations.
protected  int internalPut(java.lang.Object key, int value)
           
 java.util.Iterator iterator()
           
 java.util.Enumeration keys()
           
protected  int nextIndex(int index)
           
 int put(java.lang.Object key, int value)
           
 int putElement(java.lang.Object key, int value)
          Puts a new value in the property table with the appropriate flags
 int remove(java.lang.Object key)
          Deletes the entry.
 int size()
          Returns the current number of entries in the map.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final int NULL
Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, it's impossible to distinguish between the two.

See Also:
Constant Field Values

keys

protected java.lang.Object[] keys

nullValue

protected int nullValue

values

protected int[] values

size

protected int size

mask

protected int mask

limit

protected int limit
Constructor Detail

IntMap

public IntMap()
Create a new IntMap. Default size is 16.


IntMap

public IntMap(int size)

IntMap

public IntMap(int size,
              int nullValue)
Method Detail

getNullValue

public int getNullValue()

firstIndex

protected int firstIndex(java.lang.Object key)
This only works with binary indizes


nextIndex

protected int nextIndex(int index)

clear

public void clear()
Clear the hashmap. XXX Or should we let the GC the work an use keys = new Object[..]???


size

public int size()
Returns the current number of entries in the map.


getElement

public int getElement(java.lang.Object key)
Get an Element


get

public int get(java.lang.Object key)
Get an Element


inc

public int inc(java.lang.Object key)
Optimized operations. avoid get change put cycles.


dec

public int dec(java.lang.Object key)
Optimized operations. avoid get change put cycles.


add

public int add(java.lang.Object key,
               int off)
Optimized operations. avoid get change put cycles.


grow

protected void grow()
Expands the table


putElement

public int putElement(java.lang.Object key,
                      int value)
Puts a new value in the property table with the appropriate flags


put

public int put(java.lang.Object key,
               int value)

internalPut

protected int internalPut(java.lang.Object key,
                          int value)

remove

public int remove(java.lang.Object key)
Deletes the entry.


keys

public java.util.Enumeration keys()

iterator

public java.util.Iterator iterator()

toString

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

spieleck.de