File tree Expand file tree Collapse file tree
Section 25 Collections Frameworks/Map Interface/HashMap/Custom HashMap/src/CustomHashMap Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ extended version of the custom HashMap that includes:
2+
3+ - Iteration: Implements the Iterable interface so you can loop over all entries.
4+ - Dynamic Size Tracking: A method (`size()`) returns the current number of key-value pairs.
5+ - Load Factor Tuning: A configurable load factor (with getters and setters) and a constructor that accepts an initial
6+ capacity and load factor.
7+
8+ Extended Custom HashMap Implementation
9+
10+ Explanation of Extensions:
11+ - Iteration:
12+
13+ - The class now implements Iterable<Entry<K, V>> and provides an inner HashMapIterator that traverses each non-empty bucket
14+
15+ - You can use a for-each loop to iterate over all key-value pairs.
16+
17+ - Dynamic Size Tracking:
18+ - The size field is updated on every put() and remove() call.
19+ - The size() method returns the current count of entries.
20+
21+ - Load Factor Tuning:
22+ - The loadFactor field is configurable through constructors and the setLoadFactor() method.
23+ - The resize() method uses this load factor to determine when to double the bucket array.
You can’t perform that action at this time.
0 commit comments