cs/CollectExtension.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
internal static class CollectExtension
{
public static void ForEach<K, V>(this Dictionary<K, V> collection, Action<K, V> act)
{
var count = collection.Count;
if (count == 0)
return;
List<K> keys = new List<K>(collection.Keys);
for (int i = 0; i < count; i++)
{
var key = keys[i];
if (collection.ContainsKey(key))
act(key, collection[key]);
}
}
public static void ForEach<K, V>(this Dictionary<K, V> collection, Func<K, V, bool> act)
{
var count = collection.Count;
if (count == 0)
return;
List<K> keys = new List<K>(collection.Keys);
for (int i = 0; i < count; i++)
{
var key = keys[i];
if (collection.ContainsKey(key))
if (act(key, collection[key]))
break;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
