diff --git a/Apewer/CollectionUtility.cs b/Apewer/CollectionUtility.cs
index 90f14ab..2d6c59d 100644
--- a/Apewer/CollectionUtility.cs
+++ b/Apewer/CollectionUtility.cs
@@ -738,7 +738,7 @@ namespace Apewer
/// 输入的元素类型。
/// 输出的元素类型。
/// 要遍历的集合。
- /// 转换程序。
+ /// 转换程序,提供索引参数(从 0 开始)。
/// 新数组的元素类型。
public static TOut[] Map(this IEnumerable collection, Func selector)
{
@@ -788,7 +788,7 @@ namespace Apewer
ForEach(collection, (item, index) =>
{
callback.Invoke(item);
- return true;
+ return JumpStatement.Continue;
});
}
@@ -802,15 +802,15 @@ namespace Apewer
ForEach(collection, (item, index) =>
{
callback.Invoke(item, index);
- return true;
+ return JumpStatement.Continue;
});
}
/// 遍历每个元素,执行回调。
/// 元素的类型。
/// 元素的集合。
- /// 回调。参数为本次遍历的元素。返回 true 将继续遍历,返回 false 打断遍历。
- public static void ForEach(this IEnumerable collection, Func callback)
+ /// 回调。参数为本次遍历的元素。
+ public static void ForEach(this IEnumerable collection, Func callback)
{
if (collection == null || callback == null) return;
ForEach(collection, (item, index) =>
@@ -824,7 +824,7 @@ namespace Apewer
/// 元素的类型。
/// 元素的集合。
/// 回调。参数为本次遍历的元素和遍历的索引值,索引值从 0 开始。返回 true 将继续遍历,返回 false 打断遍历。
- public static void ForEach(this IEnumerable collection, Func callback)
+ public static void ForEach(this IEnumerable collection, Func callback)
{
if (collection == null || callback == null) return;
@@ -833,8 +833,8 @@ namespace Apewer
var count = array.Length;
for (var i = 0; i < count; i++)
{
- var @continue = callback.Invoke(array[i], i);
- if (!@continue) break;
+ var jump = callback.Invoke(array[i], i);
+ if (jump == JumpStatement.Break) break;
}
}
else
@@ -842,8 +842,8 @@ namespace Apewer
var index = 0;
foreach (var item in collection)
{
- var @continue = callback.Invoke(item, index);
- if (!@continue) break;
+ var jump = callback.Invoke(item, index);
+ if (jump == JumpStatement.Break) break;
index += 1;
}
}
@@ -854,6 +854,7 @@ namespace Apewer
/// 元素的集合。
/// 每次遍历的元素数量。
/// 回调。参数为本次遍历的元素和遍历的索引值,索引值从 0 开始。
+ ///
public static void ForEach(this IEnumerable collection, int limit, Action callback)
{
if (collection == null || callback == null) return;
@@ -861,7 +862,7 @@ namespace Apewer
ForEach(collection, limit, (items, index) =>
{
callback.Invoke(items);
- return true;
+ return JumpStatement.Continue;
});
}
@@ -870,6 +871,7 @@ namespace Apewer
/// 元素的集合。
/// 每次遍历的元素数量。
/// 回调。参数为本次遍历的元素和遍历的索引值,索引值从 0 开始。
+ ///
public static void ForEach(this IEnumerable collection, int limit, Action callback)
{
if (collection == null || callback == null) return;
@@ -877,7 +879,7 @@ namespace Apewer
ForEach(collection, limit, (items, index) =>
{
callback.Invoke(items, index);
- return true;
+ return JumpStatement.Continue;
});
}
@@ -885,8 +887,9 @@ namespace Apewer
/// 元素的类型。
/// 元素的集合。
/// 每次遍历的元素数量。
- /// 回调。参数为本次遍历的元素。返回 true 将继续遍历,返回 false 打断遍历。
- public static void ForEach(this IEnumerable collection, int limit, Func callback)
+ /// 回调。参数为本次遍历的元素。
+ ///
+ public static void ForEach(this IEnumerable collection, int limit, Func callback)
{
if (collection == null || callback == null) return;
@@ -901,8 +904,9 @@ namespace Apewer
/// 元素的类型。
/// 元素的集合。
/// 每次遍历的元素数量。
- /// 回调。参数为本次遍历的元素和遍历的索引值,索引值从 0 开始。返回 true 将继续遍历,返回 false 打断遍历。
- public static void ForEach(this IEnumerable collection, int limit, Func callback)
+ /// 回调。参数为本次遍历的元素和遍历的索引值,索引值从 0 开始。
+ ///
+ public static void ForEach(this IEnumerable collection, int limit, Func callback)
{
if (limit < 1) throw new ArgumentOutOfRangeException(nameof(limit));
if (collection == null) return;
@@ -920,8 +924,8 @@ namespace Apewer
if (start + length > total) length = total - start;
var temp = new T[length];
System.Array.Copy(array, start, temp, 0L, length);
- var @continue = callback.Invoke(temp, index);
- if (!@continue) break;
+ var jump = callback.Invoke(temp, index);
+ if (jump == JumpStatement.Break) break;
start += length;
index += 1;
@@ -938,8 +942,8 @@ namespace Apewer
while (list.Count < limit && queue.Count > 0) list.Add(queue.Dequeue());
var temp = list.ToArray();
- var @continue = callback.Invoke(temp, index);
- if (!@continue) break;
+ var jump = callback.Invoke(temp, index);
+ if (jump == JumpStatement.Break) break;
index += 1;
}