mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2026-04-20 05:24:59 +00:00
重命名改动
This commit is contained in:
parent
cedc4d29e2
commit
5e4b742505
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Milimoe.FunGame.Core.Api.Utility
|
||||
{
|
||||
public class ConcurrentQueue<T> : IEnumerable<T>
|
||||
public class ConcurrentFIFOQueue<T> : IEnumerable<T>
|
||||
{
|
||||
private System.Collections.Concurrent.ConcurrentQueue<T> Instance { get; } = [];
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
Instance.Enqueue(obj);
|
||||
}
|
||||
|
||||
public bool GetFirst(out T? obj)
|
||||
public bool Dequeue(out T? obj)
|
||||
{
|
||||
return Instance.TryDequeue(out obj);
|
||||
}
|
||||
@ -2,16 +2,32 @@
|
||||
{
|
||||
public static class LINQExtension
|
||||
{
|
||||
public static IEnumerable<T> GetPage<T>(this IEnumerable<T> list, int showPage, int pageSize)
|
||||
/// <summary>
|
||||
/// 分页查询:返回指定页码的数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">集合元素的类型</typeparam>
|
||||
/// <param name="source">要分页的源集合</param>
|
||||
/// <param name="page">页码</param>
|
||||
/// <param name="pageSize">每页显示的元素数量</param>
|
||||
/// <returns>当前页的数据</returns>
|
||||
public static IEnumerable<T> GetPage<T>(this IEnumerable<T> source, int page, int pageSize)
|
||||
{
|
||||
return [.. list.Skip((showPage - 1) * pageSize).Take(pageSize)];
|
||||
return source.Skip((page - 1) * pageSize).Take(pageSize);
|
||||
}
|
||||
|
||||
public static int MaxPage<T>(this IEnumerable<T> list, int pageSize)
|
||||
/// <summary>
|
||||
/// 计算总页数
|
||||
/// </summary>
|
||||
/// <typeparam name="T">集合元素的类型</typeparam>
|
||||
/// <param name="source">源集合</param>
|
||||
/// <param name="pageSize">每页显示的元素数量(必须大于 0)</param>
|
||||
/// <returns>总页数(至少为 1)</returns>
|
||||
public static int MaxPage<T>(this IEnumerable<T> source, int pageSize)
|
||||
{
|
||||
if (pageSize <= 0) pageSize = 1;
|
||||
int page = (int)Math.Ceiling((double)list.Count() / pageSize);
|
||||
return page > 0 ? page : 1;
|
||||
int count = source.Count();
|
||||
if (count == 0) return 1;
|
||||
return (int)Math.Ceiling((double)count / pageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user