Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NullableDoubleAverageAggregationOperator.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
NullableDoubleAverageAggregationOperator
:
InlinedAggregationOperator
<double?, Pair<double, long>, double?>
7
{
8
private
sealed
class
NullableDoubleAverageAggregationOperatorEnumerator
<TKey> :
InlinedAggregationOperatorEnumerator
<Pair<double, long>>
9
{
10
private
readonly
QueryOperatorEnumerator<double?, TKey>
_source
;
11
12
internal
NullableDoubleAverageAggregationOperatorEnumerator
(
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
=
null
;
24
TKey currentKey =
default
(TKey);
25
int
num3
= 0;
26
while
(
source
.MoveNext(
ref
currentElement2
,
ref
currentKey))
27
{
28
if
(
currentElement2
.HasValue)
29
{
30
if
((
num3
++ & 0
x3F
) == 0)
31
{
32
_cancellationToken
.
ThrowIfCancellationRequested
();
33
}
34
num +=
currentElement2
.GetValueOrDefault();
35
num2
=
checked
(
num2
+ 1);
36
}
37
}
38
currentElement
=
new
Pair<double, long>
(num,
num2
);
39
return
num2
> 0;
40
}
41
42
protected
override
void
Dispose
(
bool
disposing
)
43
{
44
_source
.
Dispose
();
45
}
46
}
47
48
internal
NullableDoubleAverageAggregationOperator
(
IEnumerable<double?>
child)
49
:
base
(child)
50
{
51
}
52
53
protected
override
double
?
InternalAggregate
(
ref
Exception
singularExceptionToThrow
)
54
{
55
checked
56
{
57
using
IEnumerator
<
Pair<double, long>
>
enumerator
= GetEnumerator(
ParallelMergeOptions
.FullyBuffered,
suppressOrderPreservation
:
true
);
58
if
(!
enumerator
.MoveNext())
59
{
60
return
null
;
61
}
62
Pair<double, long>
current =
enumerator
.Current;
63
while
(
enumerator
.MoveNext())
64
{
65
current.First +=
enumerator
.Current.First;
66
current.Second +=
enumerator
.Current.Second;
67
}
68
return
current.First / (double)current.Second;
69
}
70
}
71
72
protected
override
QueryOperatorEnumerator<Pair<double, long>
,
int
>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<double?, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
)
73
{
74
return
new
NullableDoubleAverageAggregationOperatorEnumerator<TKey>
(
source
,
index
,
cancellationToken
);
75
}
76
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
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.NullableDoubleAverageAggregationOperator.NullableDoubleAverageAggregationOperatorEnumerator._source
readonly QueryOperatorEnumerator< double?, TKey > _source
Definition
NullableDoubleAverageAggregationOperator.cs:10
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.NullableDoubleAverageAggregationOperatorEnumerator.MoveNextCore
override bool MoveNextCore(ref Pair< double, long > currentElement)
Definition
NullableDoubleAverageAggregationOperator.cs:18
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.NullableDoubleAverageAggregationOperatorEnumerator.Dispose
override void Dispose(bool disposing)
Definition
NullableDoubleAverageAggregationOperator.cs:42
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.NullableDoubleAverageAggregationOperatorEnumerator.NullableDoubleAverageAggregationOperatorEnumerator
NullableDoubleAverageAggregationOperatorEnumerator(QueryOperatorEnumerator< double?, TKey > source, int partitionIndex, CancellationToken cancellationToken)
Definition
NullableDoubleAverageAggregationOperator.cs:12
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.NullableDoubleAverageAggregationOperatorEnumerator
Definition
NullableDoubleAverageAggregationOperator.cs:9
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.NullableDoubleAverageAggregationOperator
NullableDoubleAverageAggregationOperator(IEnumerable< double?> child)
Definition
NullableDoubleAverageAggregationOperator.cs:48
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.InternalAggregate
override? double InternalAggregate(ref Exception singularExceptionToThrow)
Definition
NullableDoubleAverageAggregationOperator.cs:53
System.Linq.Parallel.NullableDoubleAverageAggregationOperator.CreateEnumerator< TKey >
override QueryOperatorEnumerator< Pair< double, long >, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< double?, TKey > source, object sharedData, CancellationToken cancellationToken)
Definition
NullableDoubleAverageAggregationOperator.cs:72
System.Linq.Parallel.NullableDoubleAverageAggregationOperator
Definition
NullableDoubleAverageAggregationOperator.cs:7
System.Linq.Parallel.QueryOperatorEnumerator.Dispose
void Dispose()
Definition
QueryOperatorEnumerator.cs:44
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.Threading.CancellationToken.ThrowIfCancellationRequested
void ThrowIfCancellationRequested()
Definition
CancellationToken.cs:115
System.Threading.CancellationToken
Definition
CancellationToken.cs:8
source
System.Linq.Parallel
System.Linq.Parallel
NullableDoubleAverageAggregationOperator.cs
Generated by
1.10.0