mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-01 09:43:33 +08:00
build
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user