Changes

Jump to: navigation, search

Computer Science/61b/Homework/hw6/dict/HashTableChained.java

151 bytes added, 05:59, 22 September 2007
m
spacing + a comment
/**
* Converts a hash code in the range Integer.MIN_VALUE...Integer.MAX_VALUE
* to a value in the range 0...(size of hash table) - 1.
*
int compFunction(int code) {
/* int returnval = (((6*code + 11) % 536870911) % table.length);
if (returnval < 0) {
returnval = returnval + table.length;
/**
* Create a new Entry object referencing the input key and associated value,
* and insert the entry into the dictionary. Return a reference to the new
* entry. Multiple entries with the same key (or even the same key and
} else {
table[targetindex].insertFront(insertion);
} tablesize++;
return insertion;
}
while (!((Entry) curnode.item()).key().equals(key)) { // if the current key is not equals() to the one we're looking for, look in the next node
curnode = curnode.next();
} return (Entry) curnode.item(); // found a match w/out throwing exceptions
} catch (list.InvalidNodeException e) { // no match for key in the list
return null;
/**
* Remove all entries from the dictionary.
*/
public void makeEmpty() {
}
/**
* Print statistical info about the hashtable: the number of keys stored in each bucket and the total number of collisions.
*/
public void printHistogram() {
String histog = "";
1,277
edits

Navigation menu