# 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();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://netjimmy.gitbook.io/code-interview-note/hashtable.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
