Files
ComiServ/Models/Truncated.cs
2024-08-27 03:29:38 -05:00

32 lines
808 B
C#

using System.Reflection.PortableExecutable;
namespace ComiServ.Models
{
public class Truncated<T>
{
public int Max { get; }
public int Count { get; }
public bool Complete { get; }
public List<T> Items { get; }
public Truncated(int max, IEnumerable<T> items)
{
if (max <= 0)
{
throw new ArgumentOutOfRangeException(nameof(max), max, "must be greater than 0");
}
Max = max;
Items = items.Take(max+1).ToList();
if (Items.Count <= max)
{
Complete = true;
}
else
{
Items.RemoveAt(max);
Complete = false;
}
Count = Items.Count;
}
}
}