# Class HashTable<K, V>

#### Type Parameters

- #### K

- #### V

#### Hierarchy

- HashTable

- Defined in src/data-structures/hash/hash-table.ts:20

#####
Index

### Constructors

constructor

### Properties

_buckets
_capacity
_size

### Accessors

buckets
capacity
size

### Methods

get
hash
put
remove

## Constructors

### constructor

- new HashTable<K, V>(capacity?): HashTable<K, V>

- The constructor initializes the capacity, size, and buckets of an object.

  #### Type Parameters

  - #### K

  - #### V

  #### Parameters

  - ##### `Optional` capacity: number = 1000

    The `capacity` parameter represents the maximum number of elements that the data structure can hold. It is an optional parameter with a default value of 1000.

  #### Returns HashTable<K, V>

  - Defined in src/data-structures/hash/hash-table.ts:54

## Properties

### `Private` _buckets

_buckets: (null | HashNode<K, V>)[]

- Defined in src/data-structures/hash/hash-table.ts:47

### `Private` _capacity

_capacity: number

- Defined in src/data-structures/hash/hash-table.ts:45

### `Private` _size

_size: number

- Defined in src/data-structures/hash/hash-table.ts:46

## Accessors

### buckets

- get buckets(): (null | HashNode<K, V>)[]

- #### Returns (null | HashNode<K, V>)[]

  - Defined in src/data-structures/hash/hash-table.ts:21
- set buckets(value): void

- #### Parameters

  - ##### value: (null | HashNode<K, V>)[]

  #### Returns void

  - Defined in src/data-structures/hash/hash-table.ts:25

### capacity

- get capacity(): number

- #### Returns number

  - Defined in src/data-structures/hash/hash-table.ts:37
- set capacity(value): void

- #### Parameters

  - ##### value: number

  #### Returns void

  - Defined in src/data-structures/hash/hash-table.ts:41

### size

- get size(): number

- #### Returns number

  - Defined in src/data-structures/hash/hash-table.ts:29
- set size(value): void

- #### Parameters

  - ##### value: number

  #### Returns void

  - Defined in src/data-structures/hash/hash-table.ts:33

## Methods

### get

- get(key): undefined | V

- The `get` function retrieves the value associated with a given key from a hash table.

  #### Parameters

  - ##### key: K

    The parameter "key" represents the key of the element that we want to retrieve from the data structure.

  #### Returns undefined | V

  The method is returning the value associated with the given key if it exists in the hash table. If the key is not found, it returns `undefined`.

  - Defined in src/data-structures/hash/hash-table.ts:118

### `Private` hash

- hash(key): number

- The hash function takes a key, converts it to a string, calculates the sum of the ASCII values of its characters, and returns the remainder when divided by the capacity of the data structure.

  #### Parameters

  - ##### key: K

    The `key` parameter represents the key that needs to be hashed. It is of type `K`, which means it can be any data type that can be converted to a string.

  #### Returns number

  The hash value of the key modulo the capacity of the data structure.

  - Defined in src/data-structures/hash/hash-table.ts:67

### put

- put(key, val): void

- The put function adds a key-value pair to a hash table, handling collisions by chaining.

  #### Parameters

  - ##### key: K

    The key parameter represents the key of the key-value pair that you want to insert into the hash table. It is of type K, which can be any data type that can be used as a key, such as a string, number, or object.

  - ##### val: V

    The `val` parameter represents the value associated with the key in the hash table.

  #### Returns void

  Nothing is being returned. The return type of the function is void, which means it does not return any value.

  - Defined in src/data-structures/hash/hash-table.ts:83

### remove

- remove(key): void

- The `remove` function removes a key-value pair from a hash table.

  #### Parameters

  - ##### key: K

    The `key` parameter represents the key of the key-value pair that needs to be removed from the hash table.

  #### Returns void

  Nothing is being returned. The `remove` method has a return type of `void`, which means it does not return any value.

  - Defined in src/data-structures/hash/hash-table.ts:138

Generated using TypeDoc