Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RepeatEnumerable.cs
Go to the documentation of this file.
3
5
6internal sealed class RepeatEnumerable<TResult> : ParallelQuery<TResult>, IParallelPartitionable<TResult>
7{
8 private sealed class RepeatEnumerator : QueryOperatorEnumerator<TResult, int>
9 {
10 private readonly TResult _element;
11
12 private readonly int _count;
13
14 private readonly int _indexOffset;
15
17
18 internal RepeatEnumerator(TResult element, int count, int indexOffset)
19 {
20 _element = element;
21 _count = count;
23 }
24
25 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TResult currentElement, ref int currentKey)
26 {
27 if (_currentIndex == null)
28 {
29 _currentIndex = new Shared<int>(-1);
30 }
31 if (_currentIndex.Value < _count - 1)
32 {
35 currentKey = _currentIndex.Value + _indexOffset;
36 return true;
37 }
38 return false;
39 }
40
41 internal override void Reset()
42 {
43 _currentIndex = null;
44 }
45 }
46
47 private readonly TResult _element;
48
49 private readonly int _count;
50
51 internal RepeatEnumerable(TResult element, int count)
53 {
54 _element = element;
55 _count = count;
56 }
57
59 {
60 int num = (_count + partitionCount - 1) / partitionCount;
62 int num2 = 0;
63 int num3 = 0;
64 while (num2 < partitionCount)
65 {
66 if (num3 + num > _count)
67 {
69 }
70 else
71 {
73 }
74 num2++;
75 num3 += num;
76 }
77 return array;
78 }
79
81 {
83 }
84}
RepeatEnumerator(TResult element, int count, int indexOffset)
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TResult currentElement, ref int currentKey)
QueryOperatorEnumerator< TResult, int >[] GetPartitions(int partitionCount)
RepeatEnumerable(TResult element, int count)
override IEnumerator< TResult > GetEnumerator()