Last active
February 27, 2019 04:22
-
-
Save tillson/e8f4b28da005da5622d645dcb2a0cef4 to your computer and use it in GitHub Desktop.
Print a HashMap that uses external chaining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void printString() { | |
int i = 0; | |
while (i < table.length) { | |
MapEntry<K, V> entry = table[i]; | |
System.out.print(i + ": "); | |
while (entry != null) { | |
System.out.print(entry.getKey() + " -> "); | |
entry = entry.getNext(); | |
} | |
System.out.println(""); | |
i++; | |
} | |
System.out.println("Size: " + size); | |
System.out.println("Load factor: " + (size * 1.0 / table.length)); | |
System.out.println("Keyset: " + keySet().toString()); | |
System.out.println("Values: " + values().toString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment