Add the codes of hashmap (#553)

of chaining and open addressing
This commit is contained in:
Yudong Jin
2023-06-14 02:01:06 +08:00
committed by GitHub
parent d3e597af94
commit 9563965a20
27 changed files with 1280 additions and 207 deletions

View File

@ -71,11 +71,11 @@ class GraphAdjList {
/* 打印邻接表 */
public void print() {
System.out.println("邻接表 =");
for (Map.Entry<Vertex, List<Vertex>> entry : adjList.entrySet()) {
for (Map.Entry<Vertex, List<Vertex>> pair : adjList.entrySet()) {
List<Integer> tmp = new ArrayList<>();
for (Vertex vertex : entry.getValue())
for (Vertex vertex : pair.getValue())
tmp.add(vertex.val);
System.out.println(entry.getKey().val + ": " + tmp + ",");
System.out.println(pair.getKey().val + ": " + tmp + ",");
}
}
}