|
|
|
|
@ -1162,10 +1162,9 @@ class Entities {
|
|
|
|
|
*/
|
|
|
|
|
public boolean containsKey(int key) {
|
|
|
|
|
Entry tab[] = table;
|
|
|
|
|
int hash = key;
|
|
|
|
|
int index = (hash & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
int index = (key & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
for (Entry e = tab[index]; e != null; e = e.next) {
|
|
|
|
|
if (e.hash == hash) {
|
|
|
|
|
if (e.hash == key) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1183,10 +1182,9 @@ class Entities {
|
|
|
|
|
*/
|
|
|
|
|
public Object get(int key) {
|
|
|
|
|
Entry tab[] = table;
|
|
|
|
|
int hash = key;
|
|
|
|
|
int index = (hash & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
int index = (key & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
for (Entry e = tab[index]; e != null; e = e.next) {
|
|
|
|
|
if (e.hash == hash) {
|
|
|
|
|
if (e.hash == key) {
|
|
|
|
|
return e.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1242,10 +1240,9 @@ class Entities {
|
|
|
|
|
public Object put(int key, Object value) {
|
|
|
|
|
// Makes sure the key is not already in the hashtable.
|
|
|
|
|
Entry tab[] = table;
|
|
|
|
|
int hash = key;
|
|
|
|
|
int index = (hash & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
int index = (key & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
for (Entry e = tab[index]; e != null; e = e.next) {
|
|
|
|
|
if (e.hash == hash) {
|
|
|
|
|
if (e.hash == key) {
|
|
|
|
|
Object old = e.value;
|
|
|
|
|
e.value = value;
|
|
|
|
|
return old;
|
|
|
|
|
@ -1257,11 +1254,11 @@ class Entities {
|
|
|
|
|
rehash();
|
|
|
|
|
|
|
|
|
|
tab = table;
|
|
|
|
|
index = (hash & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
index = (key & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Creates the new entry.
|
|
|
|
|
Entry e = new Entry(hash, key, value, tab[index]);
|
|
|
|
|
Entry e = new Entry(key, key, value, tab[index]);
|
|
|
|
|
tab[index] = e;
|
|
|
|
|
count++;
|
|
|
|
|
return null;
|
|
|
|
|
@ -1280,10 +1277,9 @@ class Entities {
|
|
|
|
|
*/
|
|
|
|
|
public Object remove(int key) {
|
|
|
|
|
Entry tab[] = table;
|
|
|
|
|
int hash = key;
|
|
|
|
|
int index = (hash & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
int index = (key & 0x7FFFFFFF) % tab.length;
|
|
|
|
|
for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) {
|
|
|
|
|
if (e.hash == hash) {
|
|
|
|
|
if (e.hash == key) {
|
|
|
|
|
if (prev != null) {
|
|
|
|
|
prev.next = e.next;
|
|
|
|
|
} else {
|
|
|
|
|
|