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