com.samskivert.util
Class CheapIntMap

java.lang.Object
  extended by com.samskivert.util.CheapIntMap

public class CheapIntMap
extends Object

A low overhead hash map using positive integers as keys that is useful for fast storage and lookup of a small and bounded number of items.


Field Summary
protected  int[] _keys
           
protected  Object[] _values
           
 
Constructor Summary
CheapIntMap(int maxSize)
          Constructs a map that can hold the specified number of items.
 
Method Summary
 void clear()
          Clears out all mappings from the table.
 Object get(int key)
          Returns the object with the specified key, null if no object exists in the table with that key.
 int getKey(int index)
          Returns the key with the specified index or -1 if no key exists at that index.
 Object getValue(int index)
          Returns the value with the specified index or null if no value exists at that index.
 void put(int key, Object value)
          Inserts the specified value into the map.
 Object remove(int key)
          Removes the mapping associated with the specified key.
 int size()
          Returns the number of mappings in this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_keys

protected int[] _keys

_values

protected Object[] _values
Constructor Detail

CheapIntMap

public CheapIntMap(int maxSize)
Constructs a map that can hold the specified number of items.

Method Detail

put

public void put(int key,
                Object value)
Inserts the specified value into the map. Note: the key must be a positive integer.


get

public Object get(int key)
Returns the object with the specified key, null if no object exists in the table with that key.


remove

public Object remove(int key)
Removes the mapping associated with the specified key. The previous value of the mapping will be returned.


clear

public void clear()
Clears out all mappings from the table.


size

public int size()
Returns the number of mappings in this table.


getKey

public int getKey(int index)
Returns the key with the specified index or -1 if no key exists at that index.


getValue

public Object getValue(int index)
Returns the value with the specified index or null if no value exists at that index.



Copyright © 2000-2008 Michael Bayne. All Rights Reserved.