Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DistinctQueryOperator.cs
Go to the documentation of this file.
4
6
7internal sealed class DistinctQueryOperator<TInputOutput> : UnaryQueryOperator<TInputOutput, TInputOutput>
8{
9 private sealed class DistinctQueryOperatorEnumerator<TKey> : QueryOperatorEnumerator<TInputOutput, int>
10 {
12
14
16
18
25
26 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, ref int currentKey)
27 {
28 TKey currentKey2 = default(TKey);
30 if (_outputLoopCount == null)
31 {
33 }
34 while (_source.MoveNext(ref currentElement2, ref currentKey2))
35 {
36 if ((_outputLoopCount.Value++ & 0x3F) == 0)
37 {
39 }
41 {
43 return true;
44 }
45 }
46 return false;
47 }
48
49 protected override void Dispose(bool disposing)
50 {
51 _source.Dispose();
52 }
53 }
54
55 private sealed class OrderedDistinctQueryOperatorEnumerator<TKey> : QueryOperatorEnumerator<TInputOutput, TKey>
56 {
58
60
61 private readonly IComparer<TKey> _keyComparer;
62
64
66
74
75 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, [AllowNull] ref TKey currentKey)
76 {
77 if (_hashLookupEnumerator == null)
78 {
80 TKey currentKey2 = default(TKey);
81 int num = 0;
82 while (_source.MoveNext(ref currentElement2, ref currentKey2))
83 {
84 if ((num++ & 0x3F) == 0)
85 {
87 }
90 {
92 }
93 }
95 }
96 if (_hashLookupEnumerator.MoveNext())
97 {
99 currentElement = current.Key.Value;
100 currentKey = current.Value;
101 return true;
102 }
103 return false;
104 }
105
106 protected override void Dispose(bool disposing)
107 {
108 _source.Dispose();
109 if (_hashLookupEnumerator != null)
110 {
111 _hashLookupEnumerator.Dispose();
112 }
113 }
114 }
115
117
118 internal override bool LimitsParallelism => false;
119
126
128 {
130 return new UnaryQueryOperatorResults(childQueryResults, this, settings, preferStriping: false);
131 }
132
144
162
164 {
165 IEnumerable<TInputOutput> source = CancellableEnumerable.Wrap(base.Child.AsSequentialQuery(token), token);
166 return source.Distinct(_comparer);
167 }
168}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void ICollection< T >. Add(T item)
Definition HashSet.cs:225
readonly QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TKey > _source
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, ref int currentKey)
DistinctQueryOperatorEnumerator(QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TKey > source, IEqualityComparer< TInputOutput > comparer, CancellationToken cancellationToken)
OrderedDistinctQueryOperatorEnumerator(QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TKey > source, IEqualityComparer< TInputOutput > comparer, IComparer< TKey > keyComparer, CancellationToken cancellationToken)
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, [AllowNull] ref TKey currentKey)
IEnumerator< KeyValuePair< Wrapper< TInputOutput >, TKey > > _hashLookupEnumerator
readonly QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TKey > _source
override QueryResults< TInputOutput > Open(QuerySettings settings, bool preferStriping)
override void WrapPartitionedStream< TKey >(PartitionedStream< TInputOutput, TKey > inputStream, IPartitionedStreamRecipient< TInputOutput > recipient, bool preferStriping, QuerySettings settings)
DistinctQueryOperator(IEnumerable< TInputOutput > source, IEqualityComparer< TInputOutput > comparer)
readonly IEqualityComparer< TInputOutput > _comparer
override IEnumerable< TInputOutput > AsSequentialQuery(CancellationToken token)
void WrapPartitionedStreamHelper< TKey >(PartitionedStream< Pair< TInputOutput, NoKeyMemoizationRequired >, TKey > hashStream, IPartitionedStreamRecipient< TInputOutput > recipient, CancellationToken cancellationToken)