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

LongSortedArrayListBucket

public class LongSortedArrayListBucket extends Object implements Bucket

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

Fields Summary
protected ArrayList
entries
Constructors Summary
LongSortedArrayListBucket()

    	entries = new ArrayList();
    
Methods Summary
public booleancontainsKey(int searchKey)

    	return (get((long) searchKey) != null);
    
public booleancontainsKey(long searchKey)

    	return (get(searchKey) != null);
    
public java.util.IteratorentryIterator()

    	return new BucketIterator(entries, true);
    
public java.lang.Objectget(int searchKey)

    	return get((long) searchKey);
    
public java.lang.Objectget(long searchKey)

    	int low = 0, high = entries.size()-1, mid;
    	long entryKey = 0;
    	LongEntry entry = null;
    	while (low <= high) {
    		mid = (low + high) / 2;
    		entry = (LongEntry) entries.get(mid);
    		entryKey = entry.key;
    		if (entryKey == searchKey) {
    			return entry.object;
    		} else if (searchKey < entryKey) {
    			high = mid - 1;
    		} else {
    			low = mid + 1;
    		}
    	}
    	return null;
    
public java.util.Iteratoriterator()

    	return new BucketIterator(entries, false);
    
public java.lang.Objectput(int searchKey, java.lang.Object object)

    	return put((long) searchKey, object);
    
public java.lang.Objectput(long searchKey, java.lang.Object object)

    	int low = 0, high = entries.size()-1, mid;
    	int entryKey = 0;
    	IntEntry entry = null;
    	while (low <= high) {
    		mid = (low + high) / 2;
    		entry = (IntEntry) entries.get(mid);
    		entryKey = entry.key;
    		if (entryKey == searchKey) {
    			Object oldObject = entry.object;
    			entry.object = object;
    			return oldObject;
    		} else if (searchKey < entryKey) {
    			high = mid - 1;
    		} else {
    			low = mid + 1;
    		}
    	}
    		
    	//totalEntries++;
   		//System.out.println("**Inserting key: " + searchKey + " at Lo: " + low);
		entries.add(low, new LongEntry(searchKey, object));
		return null;
    
public java.lang.Objectremove(int searchKey)

    	return remove((long) searchKey);
    
public java.lang.Objectremove(long searchKey)

    	int low = 0, high = entries.size()-1, mid;
    	int entryKey = 0;
    	IntEntry entry = null;

    	while (low <= high) {
    		mid = (low + high) / 2;
    		entry = (IntEntry) entries.get(mid);
    		entryKey = entry.key;
    		if (entryKey == searchKey) {
    			entries.remove(mid);
    			//totalEntries--;
    			return entry.object;
    		} else if (searchKey < entryKey) {
    			high = mid - 1;
    		} else {
    			low = mid + 1;
    		}
    	}
    	return null;
    
public intsize()

    	return entries.size();