This commit is contained in:
krahets
2023-07-25 16:42:55 +08:00
parent 0760e0865e
commit 902087ec81
23 changed files with 154 additions and 177 deletions

View File

@@ -1170,7 +1170,7 @@ comments: true
if pair not in [None, self.removed]:
self.put(pair.key, pair.val)
def print(self) -> None:
def print(self):
"""打印哈希表"""
for pair in self.buckets:
if pair is not None:

View File

@@ -374,18 +374,15 @@ comments: true
```csharp title="hash_map.cs"
/* 遍历哈希表 */
// 遍历键值对 Key->Value
foreach (var kv in map)
{
foreach (var kv in map) {
Console.WriteLine(kv.Key + " -> " + kv.Value);
}
// 单独遍历键 key
foreach (int key in map.Keys)
{
foreach (int key in map.Keys) {
Console.WriteLine(key);
}
// 单独遍历值 value
foreach (String val in map.Values)
{
foreach (String val in map.Values) {
Console.WriteLine(val);
}
```