Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FloatAverageAggregationOperator.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
FloatAverageAggregationOperator
:
InlinedAggregationOperator
<float, Pair<double, long>, float>
7
{
8
private
sealed
class
FloatAverageAggregationOperatorEnumerator
<TKey> :
InlinedAggregationOperatorEnumerator
<Pair<double, long>>
9
{
10
private
readonly
QueryOperatorEnumerator<float, TKey>
_source
;
11
12
internal
FloatAverageAggregationOperatorEnumerator
(
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
= 0f;
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 += (double)
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
FloatAverageAggregationOperator
(
IEnumerable<float>
child)
51
:
base
(child)
52
{
53
}
54
55
protected
override
float
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
0f;
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
(
float
)(current.First / (double)current.Second);
72
}
73
}
74
75
protected
override
QueryOperatorEnumerator<Pair<double, long>
,
int
>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<float, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
)
76
{
77
return
new
FloatAverageAggregationOperatorEnumerator<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.FloatAverageAggregationOperator.FloatAverageAggregationOperatorEnumerator.Dispose
override void Dispose(bool disposing)
Definition
FloatAverageAggregationOperator.cs:44
System.Linq.Parallel.FloatAverageAggregationOperator.FloatAverageAggregationOperatorEnumerator.MoveNextCore
override bool MoveNextCore(ref Pair< double, long > currentElement)
Definition
FloatAverageAggregationOperator.cs:18
System.Linq.Parallel.FloatAverageAggregationOperator.FloatAverageAggregationOperatorEnumerator._source
readonly QueryOperatorEnumerator< float, TKey > _source
Definition
FloatAverageAggregationOperator.cs:10
System.Linq.Parallel.FloatAverageAggregationOperator.FloatAverageAggregationOperatorEnumerator.FloatAverageAggregationOperatorEnumerator
FloatAverageAggregationOperatorEnumerator(QueryOperatorEnumerator< float, TKey > source, int partitionIndex, CancellationToken cancellationToken)
Definition
FloatAverageAggregationOperator.cs:12
System.Linq.Parallel.FloatAverageAggregationOperator.FloatAverageAggregationOperatorEnumerator
Definition
FloatAverageAggregationOperator.cs:9
System.Linq.Parallel.FloatAverageAggregationOperator.CreateEnumerator< TKey >
override QueryOperatorEnumerator< Pair< double, long >, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< float, TKey > source, object sharedData, CancellationToken cancellationToken)
Definition
FloatAverageAggregationOperator.cs:75
System.Linq.Parallel.FloatAverageAggregationOperator.InternalAggregate
override float InternalAggregate(ref Exception singularExceptionToThrow)
Definition
FloatAverageAggregationOperator.cs:55
System.Linq.Parallel.FloatAverageAggregationOperator.FloatAverageAggregationOperator
FloatAverageAggregationOperator(IEnumerable< float > child)
Definition
FloatAverageAggregationOperator.cs:50
System.Linq.Parallel.FloatAverageAggregationOperator
Definition
FloatAverageAggregationOperator.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
FloatAverageAggregationOperator.cs
Generated by
1.10.0