Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NullableFloatAverageAggregationOperator.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
NullableFloatAverageAggregationOperator
:
InlinedAggregationOperator
<float?, Pair<double, long>, float?>
7
{
8
private
sealed
class
NullableFloatAverageAggregationOperatorEnumerator
<TKey> :
InlinedAggregationOperatorEnumerator
<Pair<double, long>>
9
{
10
private
readonly
QueryOperatorEnumerator<float?, TKey>
_source
;
11
12
internal
NullableFloatAverageAggregationOperatorEnumerator
(
QueryOperatorEnumerator<float?, 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<float?, TKey>
source
=
_source
;
23
float
?
currentElement2
=
null
;
24
TKey currentKey =
default
(TKey);
25
int
num3
= 0;
26
while
(
source
.MoveNext(
ref
currentElement2
,
ref
currentKey))
27
{
28
if
((
num3
++ & 0
x3F
) == 0)
29
{
30
_cancellationToken
.
ThrowIfCancellationRequested
();
31
}
32
if
(
currentElement2
.HasValue)
33
{
34
num += (double)
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
NullableFloatAverageAggregationOperator
(
IEnumerable<float?>
child)
49
:
base
(child)
50
{
51
}
52
53
protected
override
float
?
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
(
float
)(current.First / (double)current.Second);
69
}
70
}
71
72
protected
override
QueryOperatorEnumerator<Pair<double, long>
,
int
>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<float?, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
)
73
{
74
return
new
NullableFloatAverageAggregationOperatorEnumerator<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.NullableFloatAverageAggregationOperator.NullableFloatAverageAggregationOperatorEnumerator._source
readonly QueryOperatorEnumerator< float?, TKey > _source
Definition
NullableFloatAverageAggregationOperator.cs:10
System.Linq.Parallel.NullableFloatAverageAggregationOperator.NullableFloatAverageAggregationOperatorEnumerator.MoveNextCore
override bool MoveNextCore(ref Pair< double, long > currentElement)
Definition
NullableFloatAverageAggregationOperator.cs:18
System.Linq.Parallel.NullableFloatAverageAggregationOperator.NullableFloatAverageAggregationOperatorEnumerator.Dispose
override void Dispose(bool disposing)
Definition
NullableFloatAverageAggregationOperator.cs:42
System.Linq.Parallel.NullableFloatAverageAggregationOperator.NullableFloatAverageAggregationOperatorEnumerator.NullableFloatAverageAggregationOperatorEnumerator
NullableFloatAverageAggregationOperatorEnumerator(QueryOperatorEnumerator< float?, TKey > source, int partitionIndex, CancellationToken cancellationToken)
Definition
NullableFloatAverageAggregationOperator.cs:12
System.Linq.Parallel.NullableFloatAverageAggregationOperator.NullableFloatAverageAggregationOperatorEnumerator
Definition
NullableFloatAverageAggregationOperator.cs:9
System.Linq.Parallel.NullableFloatAverageAggregationOperator.CreateEnumerator< TKey >
override QueryOperatorEnumerator< Pair< double, long >, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< float?, TKey > source, object sharedData, CancellationToken cancellationToken)
Definition
NullableFloatAverageAggregationOperator.cs:72
System.Linq.Parallel.NullableFloatAverageAggregationOperator.InternalAggregate
override? float InternalAggregate(ref Exception singularExceptionToThrow)
Definition
NullableFloatAverageAggregationOperator.cs:53
System.Linq.Parallel.NullableFloatAverageAggregationOperator.NullableFloatAverageAggregationOperator
NullableFloatAverageAggregationOperator(IEnumerable< float?> child)
Definition
NullableFloatAverageAggregationOperator.cs:48
System.Linq.Parallel.NullableFloatAverageAggregationOperator
Definition
NullableFloatAverageAggregationOperator.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
NullableFloatAverageAggregationOperator.cs
Generated by
1.10.0