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