FileDocCategorySizeDatePackage
IntHashMap.javaAPI DocGlassfish v2 API5286Fri May 04 22:32:10 BST 2007com.sun.enterprise.util.collection

IntHashMap

public class IntHashMap extends Object

$Source: /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/util/collection/IntHashMap.java,v $
author
$Author: tcfujii $
version
$Revision: 1.4 $ $Date: 2007/05/05 05:32:10 $

Fields Summary
int
maxBuckets
Bucket[]
buckets
Constructors Summary
public IntHashMap()

	
	  
		this(89);
	
public IntHashMap(int maxBuckets)

		this.maxBuckets = maxBuckets;
		buckets = new Bucket[maxBuckets];
		for (int i=0; i<maxBuckets; i++) {
			buckets[i] = new SortedArrayListBucket();
		}
	
public IntHashMap(Bucket[] buckets)

		this.buckets = buckets;
		this.maxBuckets = buckets.length;
	
Methods Summary
public booleancontainsKey(int key)

	    return ( (null!=get(key) ? true: false));
	
public java.lang.Objectget(int key)

		int index = Math.abs(key % maxBuckets);
		return buckets[index].get(key);
	
public com.sun.enterprise.util.collection.IntHashMap$IntHashMapIteratoriterator()

		return new IntHashMapIterator();
	
public static voidmain(java.lang.String[] args)

		
    	int count = 20;
    	long time=0, t1=0, t2 = 0;
    	String data = "SomeData_";

		IntHashMap map = new IntHashMap();
		for (int i=0; i<count; i+= 5) {
			map.put(i, data + i);
		}
		
		for (int i=1; i<count; i+= 3) {
			map.put(i, data + i);
		}
		
		for (int i=3; i<count; i+= 4) {
			map.put(i, data + i);
		}
		
		for (int i=-23; i<count; i+= 4) {
			map.put(i, data + i);
		}
		
   		for (int j=-25; j<25; j++) {
    		System.out.println("Key: " + j + "; val: " + map.get(j));
    	}
    	t2 = System.currentTimeMillis();


		Iterator iter = map.iterator();
		while (iter.hasNext()) {
			System.out.println("Got: " + iter.next());
		}
		
	
public voidprint()

		for (int i=0; i<maxBuckets; i++) {
			System.out.println("Bucket[" + i + "]: " + buckets[i]);
		}
	
public voidput(int key, java.lang.Object object)

		int index = Math.abs(key % maxBuckets);
		buckets[index].put(key, object);
	
public java.lang.Objectremove(int key)

		int index = Math.abs(key % maxBuckets);
		return buckets[index].remove(key);