Methods Summary |
---|
public boolean | contains(long key)
int index = ((int) key) & bucketmask;
for (Entry e = table[index]; e != null; e = e.next) {
if (e.key == key) {
return true;
}
}
return false;
|
public java.util.Enumeration | elements()
Vector keyList = new Vector();
for (int index=0; index<capacity; index++) {
for (Entry e = table[index]; e != null; e = e.next) {
keyList.addElement(e.value);
}
}
return keyList.elements();
|
public java.lang.Object | get(long key)
int index = ((int) key) & bucketmask;
for (Entry e = table[index]; e != null; e = e.next) {
if (e.key == key) {
return e.value;
}
}
return null;
|
public java.util.Iterator | keys()
ArrayList keyList = new ArrayList();
for (int index=0; index<capacity; index++) {
for (Entry e = table[index]; e != null; e = e.next) {
keyList.add(new Long(e.key));
}
}
return keyList.iterator();
|
public java.lang.Object | put(long key, java.lang.Object value)
int index = ((int) key) & bucketmask;
for (Entry e = table[index]; e != null; e = e.next) {
if (e.key == key) {
Object oldValue = e.value;
e.value = value;
return oldValue;
}
}
table[index] = new Entry(key, value, table[index]);
if (size++ >= threshold) {
int newCapacity = 2 * capacity;
Entry[] newTable = new Entry[newCapacity];
transfer(newTable);
table = newTable;
capacity = newCapacity;
threshold = (int)(newCapacity * loadFactor);
bucketmask = capacity-1;
}
return null;
|
public java.lang.Object | remove(long key)
int index = ((int) key) & bucketmask;
Entry prev = table[index];
Entry e = prev;
while (e != null) {
Entry next = e.next;
if (e.key == key) {
size--;
if (prev == e) {
table[index] = next;
} else {
prev.next = next;
}
return e.value;
}
prev = e;
e = next;
}
return null;
|
private void | transfer(com.sun.ejb.containers.util.LongHashMap$Entry[] newTable)Transfer all entries from current table to newTable.
Entry[] src = table;
int newCapacity = newTable.length;
int bucketmask = newCapacity-1;
for (int j = 0; j < src.length; j++) {
Entry e = src[j];
if (e != null) {
src[j] = null;
do {
Entry next = e.next;
int index = ((int) e.key) & bucketmask;
e.next = newTable[index];
newTable[index] = e;
e = next;
} while (e != null);
}
}
|
public java.util.Iterator | values()
ArrayList keyList = new ArrayList();
for (int index=0; index<capacity; index++) {
for (Entry e = table[index]; e != null; e = e.next) {
keyList.add(e.value);
}
}
return keyList.iterator();
|