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

◆ TryGetLast< TSource >() [1/2]

static TSource System.Linq.Enumerable.TryGetLast< TSource > ( this IEnumerable< TSource > source,
Func< TSource, bool > predicate,
out bool found )
inlinestaticprivate

Definition at line 5282 of file Enumerable.cs.

5283 {
5284 if (source == null)
5285 {
5286 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
5287 }
5288 if (predicate == null)
5289 {
5290 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.predicate);
5291 }
5293 {
5294 return orderedEnumerable.TryGetLast(predicate, out found);
5295 }
5297 {
5298 for (int num = list.Count - 1; num >= 0; num--)
5299 {
5300 TSource val = list[num];
5301 if (predicate(val))
5302 {
5303 found = true;
5304 return val;
5305 }
5306 }
5307 }
5308 else
5309 {
5310 using IEnumerator<TSource> enumerator = source.GetEnumerator();
5311 while (enumerator.MoveNext())
5312 {
5313 TSource val2 = enumerator.Current;
5314 if (!predicate(val2))
5315 {
5316 continue;
5317 }
5318 while (enumerator.MoveNext())
5319 {
5320 TSource current = enumerator.Current;
5321 if (predicate(current))
5322 {
5323 val2 = current;
5324 }
5325 }
5326 found = true;
5327 return val2;
5328 }
5329 }
5330 found = false;
5331 return default(TSource);
5332 }

References System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.list, System.Linq.predicate, System.Linq.source, and System.Linq.ThrowHelper.ThrowArgumentNullException().