添加了一些用于名称切换数据,可以满足随机名称的要求

This commit is contained in:
2023-11-24 19:54:59 +08:00
parent 1db23be3da
commit 7cbe59ca14
18 changed files with 250 additions and 44 deletions
+21 -1
View File
@@ -1,3 +1,5 @@
using Codice.CM.Triggers;
using System;
using System.Collections;
using System.Collections.Concurrent;
@@ -129,7 +131,7 @@ namespace XericLibrary.Runtime.MacroLibrary
#endregion
#region 应用算法
/// <summary>
/// 获取列表中随机顺序的对象
/// </summary>
@@ -144,6 +146,24 @@ namespace XericLibrary.Runtime.MacroLibrary
yield return list[index[i]];
}
/// <summary>
/// 对列表中的成员按组进行划分,并读取特定组中特定索引下的成员
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="group"></param>
/// <param name="target"></param>
/// <returns></returns>
public static IEnumerable<T> GetListGroupMember<T>(this List<T> list, int group, int target)
{
if(list.Count % group != 0)
throw new Exception("在进行列组成员获取时,组不能刚好整除列表总数");
for(int i = 0; i < list.Count; i++)
if((i % group) == target)
yield return list[i];
}
#endregion