# HashMap<K, V> class

A custom implementation of a hash map that implements the `Map<K, V>` interface.

This map uses open addressing with chaining to resolve hash collisions. Each bucket holds a list of `_HashMapEntry<K, V>` objects, allowing multiple entries to exist in the same bucket if they hash to the same index.

It supports automatic resizing when the load factor exceeds `0.75`, ensuring performance remains optimal as the number of entries grows.

This is useful for educational purposes or when custom behavior is required beyond what `dart:collection` offers.

### ⚙️ Internal Design:

- Backed by an array of lists: `List<List<_HashMapEntry<K, V>>?> _buckets`
- On collision: new entries are appended to the appropriate list
- Resize logic doubles capacity when load factor exceeds the threshold

### 📦 Example Usage:

    final map = HashMap<String, int>();
    map['apple'] = 3;
    map['banana'] = 5;
    print(map['apple']); // 3
    print(map.containsKey('banana')); // true
    print(map.length); // 2

Implemented types
  - Map<K, V>
Available extensions
  - MapExtensions
Annotations
  - @Generic(HashMap)

## Constructors

HashMap.new()
  A custom implementation of a hash map that implements the `Map<K, V>` interface.
HashMap.from(Map<K, V> map)
  Creates a hash map from an existing map.
  factory

## Properties

entries → Iterable<MapEntry<K, V>>
  The map entries of this Map.
  no setter override
hashCode → int
  The hash code for this object.
  no setter inherited
isEmpty → bool
  Whether there is no key/value pair in the map.
  no setter override
isNotEmpty → bool
  Whether there is at least one key/value pair in the map.
  no setter override
keys → Iterable<K>
  The keys of this Map.
  no setter override
length → int
  The number of key/value pairs in the map.
  no setter override
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited
values → Iterable<V>
  The values of this Map.
  no setter override

## Methods

add(K key, V item) → void

  Available on Map<K, V>, provided by the MapExtensions extension

  Add item
addAll(Map<K, V> other) → void
  Adds all key/value pairs of `other` to this map.
  override
addEntries(Iterable<MapEntry<K, V>> newEntries) → void
  Adds all key/value pairs of `newEntries` to this map.
  override
asJson({String delimiter = '_'}) → Map<String, dynamic>

  Available on Map<K, V>, provided by the MapExtensions extension

  Converts a Map to JSON with formatted keys (`_`, `-`, or `camelCase`).
cast<RK, RV>() → Map<RK, RV>
  Provides a view of this map as having `RK` keys and `RV` instances, if necessary.
  override
clear() → void
  Removes all entries from the map.
  override
computeIfAbsent(K key, V ifAbsent(K key)) → V

  Available on Map<K, V>, provided by the MapExtensions extension

  Computes a value for the given key if it is not already present in the map.
containsKey(Object? key) → bool
  Whether this map contains the given `key`.
  override
containsValue(Object? value) → bool
  Whether this map contains the given `value`.
  override
forEach(void action(K key, V value)) → void
  Applies `action` to each key/value pair of the map.
  override
get(K key) → V?

  Available on Map<K, V>, provided by the MapExtensions extension

  Get value by key
map<K2, V2>(MapEntry<K2, V2> convert(K key, V value)) → Map<K2, V2>
  Returns a new map where all entries of this map are transformed by the given `convert` function.
  override
mapKeys<K2>(K2 convert(K key)) → Map<K2, V>

  Available on Map<K, V>, provided by the MapExtensions extension

  Applies a transformation function to the keys of the Map.
merge(Map<K, V> other) → Map<K, V>

  Available on Map<K, V>, provided by the MapExtensions extension

  Merges another Map into the current Map, overriding duplicate keys.
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
put(K key, V value) → void

  Available on Map<K, V>, provided by the MapExtensions extension

  Add item
putIfAbsent(K key, V ifAbsent()) → V
  Look up the value of `key`, or add a new entry if it isn't there.
  override
remove(Object? key) → V?
  Removes `key` and its associated value, if present, from the map.
  override
removeWhere(bool test(K key, V value)) → void
  Removes all entries of this map that satisfy the given `test`.
  override
toString() → String
  A string representation of this object.
  override
update(K key, V update(V value), {V ifAbsent()?}) → V
  Updates the value for the provided `key`.
  override
updateAll(V update(K key, V value)) → void
  Updates all values.
  override

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited
operator [](Object? key) → V?
  The value for the given `key`, or `null` if `key` is not in the map.
  override
operator []=(K key, V value) → void
  Associates the `key` with the given `value`.
  override