Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DoubleAverageAggregationOperator.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
DoubleAverageAggregationOperator
:
InlinedAggregationOperator
<double, Pair<double, long>, double>
7
{
8
private
sealed
class
DoubleAverageAggregationOperatorEnumerator
<TKey> :
InlinedAggregationOperatorEnumerator
<Pair<double, long>>
9
{
10
private
readonly
QueryOperatorEnumerator<double, TKey>
_source
;
11
12
internal
DoubleAverageAggregationOperatorEnumerator
(
QueryOperatorEnumerator<double, TKey>
source
,
int
partitionIndex
,
CancellationToken
cancellationToken
)
13
:
base
(
partitionIndex
,
cancellationToken
)
14
{
15
_source
=
source
;
16
}
17
18
protected
override
bool
MoveNextCore
(
ref
Pair<double, long>
currentElement
)
19
{
20
double
num = 0.0;
21
long
num2
= 0
L
;
22
QueryOperatorEnumerator<double, TKey>
source
=
_source
;
23
double
currentElement2
= 0.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
num +=
currentElement2
;
35
num2
=
checked
(
num2
+ 1);
36
}
37
while
(
source
.MoveNext(
ref
currentElement2
,
ref
currentKey));
38
currentElement
=
new
Pair<double, long>
(num,
num2
);
39
return
true
;
40
}
41
return
false
;
42
}
43
44
protected
override
void
Dispose
(
bool
disposing
)
45
{
46
_source
.
Dispose
();
47
}
48
}
49
50
internal
DoubleAverageAggregationOperator
(
IEnumerable<double>
child)
51
:
base
(child)
52
{
53
}
54
55
protected
override
double
InternalAggregate
(
ref
Exception
singularExceptionToThrow
)
56
{
57
checked
58
{
59
using
IEnumerator
<
Pair<double, long>
>
enumerator
= GetEnumerator(
ParallelMergeOptions
.FullyBuffered,
suppressOrderPreservation
:
true
);
60
if
(!
enumerator
.MoveNext())
61
{
62
singularExceptionToThrow
=
new
InvalidOperationException
(
System
.
SR
.
NoElements
);
63
return
0.0;
64
}
65
Pair<double, long>
current =
enumerator
.Current;
66
while
(
enumerator
.MoveNext())
67
{
68
current.First +=
enumerator
.Current.First;
69
current.Second +=
enumerator
.Current.Second;
70
}
71
return
current.First / (double)current.Second;
72
}
73
}
74
75
protected
override
QueryOperatorEnumerator<Pair<double, long>
,
int
>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<double, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
)
76
{
77
return
new
DoubleAverageAggregationOperatorEnumerator<TKey>
(
source
,
index
,
cancellationToken
);
78
}
79
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.Linq.Parallel.DoubleAverageAggregationOperator.DoubleAverageAggregationOperatorEnumerator.Dispose
override void Dispose(bool disposing)
Definition
DoubleAverageAggregationOperator.cs:44
System.Linq.Parallel.DoubleAverageAggregationOperator.DoubleAverageAggregationOperatorEnumerator.MoveNextCore
override bool MoveNextCore(ref Pair< double, long > currentElement)
Definition
DoubleAverageAggregationOperator.cs:18
System.Linq.Parallel.DoubleAverageAggregationOperator.DoubleAverageAggregationOperatorEnumerator.DoubleAverageAggregationOperatorEnumerator
DoubleAverageAggregationOperatorEnumerator(QueryOperatorEnumerator< double, TKey > source, int partitionIndex, CancellationToken cancellationToken)
Definition
DoubleAverageAggregationOperator.cs:12
System.Linq.Parallel.DoubleAverageAggregationOperator.DoubleAverageAggregationOperatorEnumerator._source
readonly QueryOperatorEnumerator< double, TKey > _source
Definition
DoubleAverageAggregationOperator.cs:10
System.Linq.Parallel.DoubleAverageAggregationOperator.DoubleAverageAggregationOperatorEnumerator
Definition
DoubleAverageAggregationOperator.cs:9
System.Linq.Parallel.DoubleAverageAggregationOperator.DoubleAverageAggregationOperator
DoubleAverageAggregationOperator(IEnumerable< double > child)
Definition
DoubleAverageAggregationOperator.cs:50
System.Linq.Parallel.DoubleAverageAggregationOperator.InternalAggregate
override double InternalAggregate(ref Exception singularExceptionToThrow)
Definition
DoubleAverageAggregationOperator.cs:55
System.Linq.Parallel.DoubleAverageAggregationOperator.CreateEnumerator< TKey >
override QueryOperatorEnumerator< Pair< double, long >, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< double, TKey > source, object sharedData, CancellationToken cancellationToken)
Definition
DoubleAverageAggregationOperator.cs:75
System.Linq.Parallel.DoubleAverageAggregationOperator
Definition
DoubleAverageAggregationOperator.cs:7
System.Linq.Parallel.InlinedAggregationOperatorEnumerator< Pair< double, 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.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
DoubleAverageAggregationOperator.cs
Generated by
1.10.0