Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IntAverageAggregationOperator.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
using
System.Threading
;
3
4
namespace
System.Linq.Parallel
;
5
6
internal
sealed
class
IntAverageAggregationOperator
:
InlinedAggregationOperator
<int, Pair<long, long>, double>
7
{
8
private
sealed
class
IntAverageAggregationOperatorEnumerator
<TKey> :
InlinedAggregationOperatorEnumerator
<Pair<long, long>>
9
{
10
private
readonly
QueryOperatorEnumerator<int, TKey>
_source
;
11
12
internal
IntAverageAggregationOperatorEnumerator
(
QueryOperatorEnumerator<int, TKey>
source
,
int
partitionIndex
,
CancellationToken
cancellationToken
)
13
:
base
(
partitionIndex
,
cancellationToken
)
14
{
15
_source
=
source
;
16
}
17
18
protected
override
bool
MoveNextCore
(
ref
Pair<long, long>
currentElement
)
19
{
20
long
num = 0
L
;
21
long
num2
= 0
L
;
22
QueryOperatorEnumerator<int, TKey>
source
=
_source
;
23
int
currentElement2
= 0;
24
TKey currentKey =
default
(TKey);
25
if
(
source
.MoveNext(
ref
currentElement2
,
ref
currentKey))
26
{
27
int
num3
= 0;
28
do
29
{
30
if
((
num3
++ & 0
x3F
) == 0)
31
{
32
_cancellationToken
.
ThrowIfCancellationRequested
();
33
}
34
checked
35
{
36
num +=
currentElement2
;
37
num2
++;
38
}
39
}
40
while
(
source
.MoveNext(
ref
currentElement2
,
ref
currentKey));
41
currentElement
=
new
Pair<long, long>
(num,
num2
);
42
return
true
;
43
}
44
return
false
;
45
}
46
47
protected
override
void
Dispose
(
bool
disposing
)
48
{
49
_source
.
Dispose
();
50
}
51
}
52
53
internal
IntAverageAggregationOperator
(
IEnumerable<int>
child)
54
:
base
(child)
55
{
56
}
57
58
protected
override
double
InternalAggregate
(
ref
Exception
singularExceptionToThrow
)
59
{
60
checked
61
{
62
using
IEnumerator
<
Pair<long, long>
>
enumerator
= GetEnumerator(
ParallelMergeOptions
.FullyBuffered,
suppressOrderPreservation
:
true
);
63
if
(!
enumerator
.MoveNext())
64
{
65
singularExceptionToThrow
=
new
InvalidOperationException
(
System
.
SR
.
NoElements
);
66
return
0.0;
67
}
68
Pair<long, long>
current =
enumerator
.Current;
69
while
(
enumerator
.MoveNext())
70
{
71
current.First +=
enumerator
.Current.First;
72
current.Second +=
enumerator
.Current.Second;
73
}
74
return
(
double
)current.First / (double)current.Second;
75
}
76
}
77
78
protected
override
QueryOperatorEnumerator<Pair<long, long>
,
int
>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<int, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
)
79
{
80
return
new
IntAverageAggregationOperatorEnumerator<TKey>
(
source
,
index
,
cancellationToken
);
81
}
82
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.Linq.Parallel.InlinedAggregationOperatorEnumerator< Pair< long, long > >::_cancellationToken
CancellationToken _cancellationToken
Definition
InlinedAggregationOperatorEnumerator.cs:12
System.Linq.Parallel.InlinedAggregationOperatorEnumerator
Definition
InlinedAggregationOperatorEnumerator.cs:7
System.Linq.Parallel.InlinedAggregationOperator
Definition
InlinedAggregationOperator.cs:8
System.Linq.Parallel.IntAverageAggregationOperator.IntAverageAggregationOperatorEnumerator.MoveNextCore
override bool MoveNextCore(ref Pair< long, long > currentElement)
Definition
IntAverageAggregationOperator.cs:18
System.Linq.Parallel.IntAverageAggregationOperator.IntAverageAggregationOperatorEnumerator.Dispose
override void Dispose(bool disposing)
Definition
IntAverageAggregationOperator.cs:47
System.Linq.Parallel.IntAverageAggregationOperator.IntAverageAggregationOperatorEnumerator.IntAverageAggregationOperatorEnumerator
IntAverageAggregationOperatorEnumerator(QueryOperatorEnumerator< int, TKey > source, int partitionIndex, CancellationToken cancellationToken)
Definition
IntAverageAggregationOperator.cs:12
System.Linq.Parallel.IntAverageAggregationOperator.IntAverageAggregationOperatorEnumerator._source
readonly QueryOperatorEnumerator< int, TKey > _source
Definition
IntAverageAggregationOperator.cs:10
System.Linq.Parallel.IntAverageAggregationOperator.IntAverageAggregationOperatorEnumerator
Definition
IntAverageAggregationOperator.cs:9
System.Linq.Parallel.IntAverageAggregationOperator.CreateEnumerator< TKey >
override QueryOperatorEnumerator< Pair< long, long >, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< int, TKey > source, object sharedData, CancellationToken cancellationToken)
Definition
IntAverageAggregationOperator.cs:78
System.Linq.Parallel.IntAverageAggregationOperator.IntAverageAggregationOperator
IntAverageAggregationOperator(IEnumerable< int > child)
Definition
IntAverageAggregationOperator.cs:53
System.Linq.Parallel.IntAverageAggregationOperator.InternalAggregate
override double InternalAggregate(ref Exception singularExceptionToThrow)
Definition
IntAverageAggregationOperator.cs:58
System.Linq.Parallel.IntAverageAggregationOperator
Definition
IntAverageAggregationOperator.cs:7
System.Linq.Parallel.QueryOperatorEnumerator.Dispose
void Dispose()
Definition
QueryOperatorEnumerator.cs:44
System.SR.NoElements
static string NoElements
Definition
SR.cs:16
System.SR
Definition
SR.cs:7
System.Collections.Generic.IEnumerator
Definition
IEnumerator.cs:4
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Linq.Parallel
Definition
AnyAllSearchOperator.cs:5
System.Linq.ExceptionArgument.source
@ source
System.Linq.ExceptionArgument.index
@ index
System.Linq.ExceptionArgument.count
@ count
System.Linq.ParallelMergeOptions
ParallelMergeOptions
Definition
ParallelMergeOptions.cs:4
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.cancellationToken
@ cancellationToken
System.ConsoleKey.L
@ L
System
Definition
BlockingCollection.cs:8
System.Threading.CancellationToken.ThrowIfCancellationRequested
void ThrowIfCancellationRequested()
Definition
CancellationToken.cs:115
System.Threading.CancellationToken
Definition
CancellationToken.cs:8
source
System.Linq.Parallel
System.Linq.Parallel
IntAverageAggregationOperator.cs
Generated by
1.10.0