Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GroupByElementSelectorQueryOperatorEnumerator.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
GroupByElementSelectorQueryOperatorEnumerator
<TSource,
TGroupKey
, TElement, TOrderKey> :
GroupByQueryOperatorEnumerator
<TSource, TGroupKey, TElement, TOrderKey>
7
{
8
private
readonly
Func<TSource, TElement>
_elementSelector
;
9
10
internal
GroupByElementSelectorQueryOperatorEnumerator
(
QueryOperatorEnumerator
<
Pair<TSource, TGroupKey>
, TOrderKey>
source
,
IEqualityComparer<TGroupKey>
keyComparer,
Func<TSource, TElement>
elementSelector
,
CancellationToken
cancellationToken
)
11
:
base
(
source
, keyComparer,
cancellationToken
)
12
{
13
_elementSelector
=
elementSelector
;
14
}
15
16
protected
override
HashLookup<Wrapper<TGroupKey>
,
ListChunk<TElement>
>
BuildHashLookup
()
17
{
18
HashLookup<Wrapper<TGroupKey>
,
ListChunk<TElement>
>
hashLookup
=
new
HashLookup<Wrapper<TGroupKey>
,
ListChunk<TElement>
>(
new
WrapperEqualityComparer<TGroupKey>
(
_keyComparer
));
19
Pair<TSource, TGroupKey>
currentElement
=
default
(
Pair<TSource, TGroupKey>
);
20
TOrderKey currentKey =
default
(TOrderKey);
21
int
num = 0;
22
while
(
_source
.MoveNext(
ref
currentElement
,
ref
currentKey))
23
{
24
if
((num++ & 0
x3F
) == 0)
25
{
26
_cancellationToken
.
ThrowIfCancellationRequested
();
27
}
28
Wrapper<TGroupKey>
key
=
new
Wrapper<TGroupKey>
(
currentElement
.Second);
29
ListChunk<TElement>
value
=
null
;
30
if
(!
hashLookup
.
TryGetValue
(
key
,
ref
value
))
31
{
32
value
=
new
ListChunk<TElement>
(2);
33
hashLookup
.
Add
(
key
,
value
);
34
}
35
value
.
Add
(
_elementSelector
(
currentElement
.First));
36
}
37
return
hashLookup
;
38
}
39
}
System.Collections.Generic.Dictionary.TryGetValue
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
Definition
Dictionary.cs:1419
System.Collections.Generic.Dictionary.Add
void Add(TKey key, TValue value)
Definition
Dictionary.cs:873
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Linq.Parallel.GroupByElementSelectorQueryOperatorEnumerator.BuildHashLookup
override HashLookup< Wrapper< TGroupKey >, ListChunk< TElement > > BuildHashLookup()
Definition
GroupByElementSelectorQueryOperatorEnumerator.cs:16
System.Linq.Parallel.GroupByElementSelectorQueryOperatorEnumerator.GroupByElementSelectorQueryOperatorEnumerator
GroupByElementSelectorQueryOperatorEnumerator(QueryOperatorEnumerator< Pair< TSource, TGroupKey >, TOrderKey > source, IEqualityComparer< TGroupKey > keyComparer, Func< TSource, TElement > elementSelector, CancellationToken cancellationToken)
Definition
GroupByElementSelectorQueryOperatorEnumerator.cs:10
System.Linq.Parallel.GroupByElementSelectorQueryOperatorEnumerator._elementSelector
readonly Func< TSource, TElement > _elementSelector
Definition
GroupByElementSelectorQueryOperatorEnumerator.cs:8
System.Linq.Parallel.GroupByElementSelectorQueryOperatorEnumerator
Definition
GroupByElementSelectorQueryOperatorEnumerator.cs:7
System.Linq.Parallel.GroupByQueryOperatorEnumerator._cancellationToken
readonly CancellationToken _cancellationToken
Definition
GroupByQueryOperatorEnumerator.cs:20
System.Linq.Parallel.GroupByQueryOperatorEnumerator._keyComparer
readonly IEqualityComparer< TGroupKey > _keyComparer
Definition
GroupByQueryOperatorEnumerator.cs:18
System.Linq.Parallel.GroupByQueryOperatorEnumerator._source
readonly QueryOperatorEnumerator< Pair< TSource, TGroupKey >, TOrderKey > _source
Definition
GroupByQueryOperatorEnumerator.cs:16
System.Linq.Parallel.GroupByQueryOperatorEnumerator
Definition
GroupByQueryOperatorEnumerator.cs:8
System.Linq.Parallel.QueryOperatorEnumerator
Definition
QueryOperatorEnumerator.cs:8
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Linq.Parallel
Definition
AnyAllSearchOperator.cs:5
System.Linq.ExceptionArgument.source
@ source
System.Linq.ExceptionArgument.elementSelector
@ elementSelector
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.value
@ value
System.ExceptionArgument.key
@ key
System.ExceptionArgument.cancellationToken
@ cancellationToken
System.Threading.CancellationToken.ThrowIfCancellationRequested
void ThrowIfCancellationRequested()
Definition
CancellationToken.cs:115
System.Threading.CancellationToken
Definition
CancellationToken.cs:8
source
System.Linq.Parallel
System.Linq.Parallel
GroupByElementSelectorQueryOperatorEnumerator.cs
Generated by
1.10.0