三国卡牌客户端基础资源仓库
yyl
2025-08-25 214fe94eaf7f09741a7857775dfffe8c3b83c75c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using Cysharp.Threading.Tasks.Internal;
using System.Threading;
 
namespace Cysharp.Threading.Tasks.Linq
{
    public static partial class UniTaskAsyncEnumerable
    {
        public static IUniTaskAsyncEnumerable<int> Range(int start, int count)
        {
            if (count < 0) throw Error.ArgumentOutOfRange(nameof(count));
 
            var end = (long)start + count - 1L;
            if (end > int.MaxValue) throw Error.ArgumentOutOfRange(nameof(count));
 
            if (count == 0) UniTaskAsyncEnumerable.Empty<int>();
 
            return new Cysharp.Threading.Tasks.Linq.Range(start, count);
        }
    }
 
    internal class Range : IUniTaskAsyncEnumerable<int>
    {
        readonly int start;
        readonly int end;
 
        public Range(int start, int count)
        {
            this.start = start;
            this.end = start + count;
        }
 
        public IUniTaskAsyncEnumerator<int> GetAsyncEnumerator(CancellationToken cancellationToken = default)
        {
            return new _Range(start, end, cancellationToken);
        }
 
        class _Range : IUniTaskAsyncEnumerator<int>
        {
            readonly int start;
            readonly int end;
            int current;
            CancellationToken cancellationToken;
 
            public _Range(int start, int end, CancellationToken cancellationToken)
            {
                this.start = start;
                this.end = end;
                this.cancellationToken = cancellationToken;
 
                this.current = start - 1;
            }
 
            public int Current => current;
 
            public UniTask<bool> MoveNextAsync()
            {
                cancellationToken.ThrowIfCancellationRequested();
 
                current++;
 
                if (current != end)
                {
                    return CompletedTasks.True;
                }
 
                return CompletedTasks.False;
            }
 
            public UniTask DisposeAsync()
            {
                return default;
            }
        }
    }
}