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

SortedArrayListBucket

public class SortedArrayListBucket extends Object implements Bucket

Fields Summary
protected ArrayList
entries
Constructors Summary
SortedArrayListBucket()

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

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

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

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

    	return get((int) searchKey);
    
public java.lang.Objectget(int 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) {
    			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(long searchKey, java.lang.Object object)

    	return put((int) searchKey, object);
    
public java.lang.Objectput(int 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 IntEntry(searchKey, object));
		return null;
    
public java.lang.Objectremove(long searchKey)

    	return remove((int) searchKey);
    
public java.lang.Objectremove(int 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();