General Tips


Also see hash table concepts for algorithms and other helpful information.

Iterative Coding
One approach is to code the hash table iteratively
Initializing Buckets
When constructing a new hash table, we want to initialize it with an array of empty buckets so it has some initial capacity.

Also see the "load ratio" discussion.
//given "length" (i.e., the # of buckets to construct)
//A DynamicArray may be substituded for LinkedList
let newBuckets = DynamicArray.newEmpty();
for (let i = 0; i < length; i++)
	newBuckets.add(LinkedList.newEmpty());
//Set ivar
this.buckets = newBuckets;


Java Tips


Java Nested Generic Params Example
Nested Java generics can get complex.

One tip is to break them down (to help undersanding).
Given:
	DynamicList<DynamicList<Association<K, V>>> table;

	<DynamicList<Association<K, V>>>
	//The generic param for the outer DynamicList is also a DynamicList

	<Association<K, V>>
	//The generic param for the inner DynamicList is an Association

	<K, V>
	//The generic params for Association are K and V


JavaScript Tips


JavaScript does not have built-in hash functions. The discussion on hash function will guide you to code hash functions. Place your hash function code in any of your JavaScript files (e.g., you could put in in your file with the HashTable class (before or after the class).

If you have an ivar to keep track of structure size, name the ivar "_size" to avoid a conflict with the method named "size".