Methods Summary |
---|
public boolean | containsKey(long searchKey)
return (get(searchKey) != null);
|
public boolean | containsKey(int searchKey)
return (get((long) searchKey) != null);
|
public java.util.Iterator | entryIterator()
return new BucketIterator(entries, true);
|
public java.lang.Object | get(long searchKey)
return get((int) searchKey);
|
public java.lang.Object | get(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.Iterator | iterator()
return new BucketIterator(entries, false);
|
public java.lang.Object | put(long searchKey, java.lang.Object object)
return put((int) searchKey, object);
|
public java.lang.Object | put(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.Object | remove(long searchKey)
return remove((int) searchKey);
|
public java.lang.Object | remove(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 int | size()
return entries.size();
|