This section describes the required headers for a hash table.

We need to have pre-specified headers so that other coders know how to use the hash table.

Only the headers are required. "How" the implementation (logic) is coded is coder's choice.

Note: All of the required headers must be public.

Class Header


JavaScript
Class header in JavaScript
class HashTable

Java
public class HashTable<K, V> implements HashTableIdea<K, V>
Where:
  • K - generic parameter for key data type
  • V - generic parameter for the value data type

By "value" we mean the elements stored in the hash table (Customers, Employees, etc). If pre-testing, value could also be prim-like objects such as integers, strings, etc.


Constructor Method Headers


The constructors are simple static factory methods

JavaScript
//No-args constructor
//Returns new HashTable with initial capacity of 16
//max load ratio is coder's choice
static newEmpty()

//Constructor with two params (returns HashTable per the params)
static fromCapacityMaxLoadRatio(initCapacity, maxLoadRatio)
Java
//No-args constructor
//Returns new HashTable with initial capacity of 16
//max load ratio is coder's choice
public static <T, U> HashTable<T, U> newEmpty()

//Constructor with two params (returns HashTable per the params)
public static HashTable fromCapacityMaxLoadRatio(int initCapacity, double maxLoadRatio)


Instance Method Headers (ADT)