Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DefaultIfEmptyQueryOperator.cs
Go to the documentation of this file.
4
6
7internal sealed class DefaultIfEmptyQueryOperator<TSource> : UnaryQueryOperator<TSource, TSource>
8{
9 private sealed class DefaultIfEmptyQueryOperatorEnumerator<TKey> : QueryOperatorEnumerator<TSource, TKey>
10 {
12
13 private bool _lookedForEmpty;
14
15 private readonly int _partitionIndex;
16
17 private readonly int _partitionCount;
18
19 private readonly TSource _defaultValue;
20
22
23 private readonly CountdownEvent _sharedLatch;
24
26
37
38 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TSource currentElement, [AllowNull] ref TKey currentKey)
39 {
40 bool flag = _source.MoveNext(ref currentElement, ref currentKey);
41 if (!_lookedForEmpty)
42 {
43 _lookedForEmpty = true;
44 if (!flag)
45 {
46 if (_partitionIndex == 0)
47 {
51 {
53 currentKey = default(TKey);
54 return true;
55 }
56 return false;
57 }
59 }
60 if (_partitionIndex != 0)
61 {
63 }
64 }
65 return flag;
66 }
67
68 protected override void Dispose(bool disposing)
69 {
71 }
72 }
73
74 private readonly TSource _defaultValue;
75
76 internal override bool LimitsParallelism => false;
77
79 : base(child)
80 {
82 SetOrdinalIndexState(base.Child.OrdinalIndexState.Worse(OrdinalIndexState.Correct));
83 }
84
85 internal override QueryResults<TSource> Open(QuerySettings settings, bool preferStriping)
86 {
89 }
90
103
105 {
106 return base.Child.AsSequentialQuery(token).DefaultIfEmpty(_defaultValue);
107 }
108}
DefaultIfEmptyQueryOperatorEnumerator(QueryOperatorEnumerator< TSource, TKey > source, TSource defaultValue, int partitionIndex, int partitionCount, Shared< int > sharedEmptyCount, CountdownEvent sharedLatch, CancellationToken cancelToken)
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TSource currentElement, [AllowNull] ref TKey currentKey)
override IEnumerable< TSource > AsSequentialQuery(CancellationToken token)
override void WrapPartitionedStream< TKey >(PartitionedStream< TSource, TKey > inputStream, IPartitionedStreamRecipient< TSource > recipient, bool preferStriping, QuerySettings settings)
override QueryResults< TSource > Open(QuerySettings settings, bool preferStriping)
DefaultIfEmptyQueryOperator(IEnumerable< TSource > child, TSource defaultValue)
bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TElement currentElement, [AllowNull] ref TKey currentKey)
static int Increment(ref int location)