> For the complete documentation index, see [llms.txt](https://netjimmy.gitbook.io/code-interview-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://netjimmy.gitbook.io/code-interview-note/hashtable.md).

# 10. HashTable

## HashTable

* put (k,v) : 放入 (k,v)
* get (k) : return v

## HashSet and HashMap

若要改寫hash function計算對象，必須在class改寫equals() and hashCode()

```java
@Override
public boolean equals (Object obj){
    if (obj == null || !(obj instanceof ContactList)){
        return false;
    }
    return new HashSet(names).equals(new HashSet(((ContactList)obj).names));
}

@Override
public int hashCode(){
    return new HashSet(names).hashCode();
}
```
