Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FloatMinMaxAggregationOperator.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
FloatMinMaxAggregationOperator
:
InlinedAggregationOperator
<float, float, float>
7
{
8
private
sealed
class
FloatMinMaxAggregationOperatorEnumerator
<TKey> :
InlinedAggregationOperatorEnumerator
<float>
9
{
10
private
readonly
QueryOperatorEnumerator<float, TKey>
_source
;
11
12
private
readonly
int
_sign
;
13
14
internal
FloatMinMaxAggregationOperatorEnumerator
(
QueryOperatorEnumerator<float, TKey>
source
,
int
partitionIndex
,
int
sign,
CancellationToken
cancellationToken
)
15
:
base
(
partitionIndex
,
cancellationToken
)
16
{
17
_source
=
source
;
18
_sign
= sign;
19
}
20
21
protected
override
bool
MoveNextCore
(
ref
float
currentElement
)
22
{
23
QueryOperatorEnumerator<float, TKey>
source
=
_source
;
24
TKey currentKey =
default
(TKey);
25
if
(
source
.MoveNext(
ref
currentElement
,
ref
currentKey))
26
{
27
int
num = 0;
28
if
(
_sign
== -1)
29
{
30
float
currentElement2
= 0f;
31
while
(
source
.MoveNext(
ref
currentElement2
,
ref
currentKey))
32
{
33
if
((num++ & 0
x3F
) == 0)
34
{
35
_cancellationToken
.
ThrowIfCancellationRequested
();
36
}
37
if
(
currentElement2
<
currentElement
||
float
.IsNaN(
currentElement2
))
38
{
39
currentElement
=
currentElement2
;
40
}
41
}
42
}
43
else
44
{
45
float
currentElement3
= 0f;
46
while
(
source
.MoveNext(
ref
currentElement3
,
ref
currentKey))
47
{
48
if
((num++ & 0
x3F
) == 0)
49
{
50
_cancellationToken
.
ThrowIfCancellationRequested
();
51
}
52
if
(
currentElement3
>
currentElement
||
float
.IsNaN(
currentElement
))
53
{
54
currentElement
=
currentElement3
;
55
}
56
}
57
}
58
return
true
;
59
}
60
return
false
;
61
}
62
63
protected
override
void
Dispose
(
bool
disposing
)
64
{
65
_source
.
Dispose
();
66
}
67
}
68
69
private
readonly
int
_sign
;
70
71
internal
FloatMinMaxAggregationOperator
(
IEnumerable<float>
child,
int
sign)
72
:
base
(child)
73
{
74
_sign
= sign;
75
}
76
77
protected
override
float
InternalAggregate
(
ref
Exception
singularExceptionToThrow
)
78
{
79
using
IEnumerator
<
float
>
enumerator
= GetEnumerator(
ParallelMergeOptions
.FullyBuffered,
suppressOrderPreservation
:
true
);
80
if
(!
enumerator
.MoveNext())
81
{
82
singularExceptionToThrow
=
new
InvalidOperationException
(
System
.
SR
.
NoElements
);
83
return
0f;
84
}
85
float
num =
enumerator
.Current;
86
if
(
_sign
== -1)
87
{
88
while
(
enumerator
.MoveNext())
89
{
90
float
current =
enumerator
.Current;
91
if
(current < num ||
float
.IsNaN(current))
92
{
93
num = current;
94
}
95
}
96
}
97
else
98
{
99
while
(
enumerator
.MoveNext())
100
{
101
float
current2
=
enumerator
.Current;
102
if
(
current2
> num ||
float
.IsNaN(num))
103
{
104
num =
current2
;
105
}
106
}
107
}
108
return
num;
109
}
110
111
protected
override
QueryOperatorEnumerator<float, int>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<float, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
)
112
{
113
return
new
FloatMinMaxAggregationOperatorEnumerator<TKey>
(
source
,
index
,
_sign
,
cancellationToken
);
114
}
115
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperatorEnumerator.MoveNextCore
override bool MoveNextCore(ref float currentElement)
Definition
FloatMinMaxAggregationOperator.cs:21
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperatorEnumerator.FloatMinMaxAggregationOperatorEnumerator
FloatMinMaxAggregationOperatorEnumerator(QueryOperatorEnumerator< float, TKey > source, int partitionIndex, int sign, CancellationToken cancellationToken)
Definition
FloatMinMaxAggregationOperator.cs:14
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperatorEnumerator._sign
readonly int _sign
Definition
FloatMinMaxAggregationOperator.cs:12
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperatorEnumerator._source
readonly QueryOperatorEnumerator< float, TKey > _source
Definition
FloatMinMaxAggregationOperator.cs:10
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperatorEnumerator.Dispose
override void Dispose(bool disposing)
Definition
FloatMinMaxAggregationOperator.cs:63
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperatorEnumerator
Definition
FloatMinMaxAggregationOperator.cs:9
System.Linq.Parallel.FloatMinMaxAggregationOperator.CreateEnumerator< TKey >
override QueryOperatorEnumerator< float, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< float, TKey > source, object sharedData, CancellationToken cancellationToken)
Definition
FloatMinMaxAggregationOperator.cs:111
System.Linq.Parallel.FloatMinMaxAggregationOperator.InternalAggregate
override float InternalAggregate(ref Exception singularExceptionToThrow)
Definition
FloatMinMaxAggregationOperator.cs:77
System.Linq.Parallel.FloatMinMaxAggregationOperator.FloatMinMaxAggregationOperator
FloatMinMaxAggregationOperator(IEnumerable< float > child, int sign)
Definition
FloatMinMaxAggregationOperator.cs:71
System.Linq.Parallel.FloatMinMaxAggregationOperator._sign
readonly int _sign
Definition
FloatMinMaxAggregationOperator.cs:69
System.Linq.Parallel.FloatMinMaxAggregationOperator
Definition
FloatMinMaxAggregationOperator.cs:7
System.Linq.Parallel.InlinedAggregationOperatorEnumerator< float >::_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
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
FloatMinMaxAggregationOperator.cs
Generated by
1.10.0