Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TakeRangeFromEndIterator< TSource >()

static IEnumerable< TSource > System.Linq.Enumerable.TakeRangeFromEndIterator< TSource > ( IEnumerable< TSource > source,
bool isStartIndexFromEnd,
int startIndex,
bool isEndIndexFromEnd,
int endIndex )
inlinestaticprivate

Definition at line 8131 of file Enumerable.cs.

8132 {
8133 if (source.TryGetNonEnumeratedCount(out var count2))
8134 {
8137 if (startIndex >= endIndex)
8138 {
8139 yield break;
8140 }
8141 foreach (TSource item in TakeRangeIterator(source, startIndex, endIndex))
8142 {
8143 yield return item;
8144 }
8145 yield break;
8146 }
8148 {
8151 {
8152 if (!enumerator2.MoveNext())
8153 {
8154 yield break;
8155 }
8156 queue = new Queue<TSource>();
8157 queue.Enqueue(enumerator2.Current);
8158 count2 = 1;
8159 while (enumerator2.MoveNext())
8160 {
8161 if (count2 < startIndex)
8162 {
8163 queue.Enqueue(enumerator2.Current);
8164 count2++;
8165 continue;
8166 }
8167 do
8168 {
8169 queue.Dequeue();
8170 queue.Enqueue(enumerator2.Current);
8171 count2 = checked(count2 + 1);
8172 }
8173 while (enumerator2.MoveNext());
8174 break;
8175 }
8176 }
8180 {
8181 yield return queue.Dequeue();
8182 }
8183 yield break;
8184 }
8186 {
8187 for (count2 = 0; count2 < startIndex; count2++)
8188 {
8189 if (!enumerator.MoveNext())
8190 {
8191 break;
8192 }
8193 }
8194 if (count2 != startIndex)
8195 {
8196 yield break;
8197 }
8199 while (enumerator.MoveNext())
8200 {
8201 if (queue.Count == endIndex)
8202 {
8203 do
8204 {
8205 queue.Enqueue(enumerator.Current);
8206 yield return queue.Dequeue();
8207 }
8208 while (enumerator.MoveNext());
8209 break;
8210 }
8211 queue.Enqueue(enumerator.Current);
8212 }
8213 }
8214 static int CalculateEndIndex(bool isEndIndexFromEnd, int endIndex, int count)
8215 {
8216 return Math.Min(count, isEndIndexFromEnd ? (count - endIndex) : endIndex);
8217 }
8218 static int CalculateStartIndex(bool isStartIndexFromEnd, int startIndex, int count)
8219 {
8220 return Math.Max(0, isStartIndexFromEnd ? (count - startIndex) : startIndex);
8221 }
8222 }

References System.Linq.count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.endIndex, System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.item, System.Math.Max(), System.Math.Min(), System.Linq.source, and System.startIndex.