Methods Summary |
---|
public void | clear()Remove all key/value assocaition. This tries to save a bit of GC'ing
by at least keeping the fBuckets array around.
for (int i=0; i<fTableSize; i++) {
fBuckets[i] = null;
}
fNum = 0;
|
public java.lang.Object | get(java.lang.Object key)Get the value associated with the given key.
int bucket = (key.hashCode() & 0x7FFFFFFF) % fTableSize;
Entry entry = search(key, bucket);
if (entry != null) {
return entry.value;
}
return null;
|
public int | getLength()Get the number of key/value pairs stored in this table.
return fNum;
|
public int | getValues(java.lang.Object[] elements, int from)Add all values to the given array. The array must have enough entry.
for (int i=0, j=0; i<fTableSize && j<fNum; i++) {
for (Entry entry = fBuckets[i]; entry != null; entry = entry.next) {
elements[from+j] = entry.value;
j++;
}
}
return fNum;
|
public org.apache.xerces.util.SymbolHash | makeClone()Make a clone of this object.
SymbolHash newTable = new SymbolHash(fTableSize);
newTable.fNum = fNum;
for (int i = 0; i < fTableSize; i++) {
if (fBuckets[i] != null)
newTable.fBuckets[i] = fBuckets[i].makeClone();
}
return newTable;
|
public void | put(java.lang.Object key, java.lang.Object value)Adds the key/value mapping to the key table. If the key already exists,
the previous value associated with this key is overwritten by the new
value.
int bucket = (key.hashCode() & 0x7FFFFFFF) % fTableSize;
Entry entry = search(key, bucket);
// replace old value
if (entry != null) {
entry.value = value;
}
// create new entry
else {
entry = new Entry(key, value, fBuckets[bucket]);
fBuckets[bucket] = entry;
fNum++;
}
|
protected org.apache.xerces.util.SymbolHash$Entry | search(java.lang.Object key, int bucket)
// search for identical key
for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (key.equals(entry.key))
return entry;
}
return null;
|