public static TSource FirstOrDefault <TSource>(this List <TSource> source, Func <TSource, bool> predicate) { var aggregate = new FirstOrDefaultPredicate <TSource>(predicate); ListSegmentNode.ProcessList(source, ref aggregate); return(aggregate.GetResult()); }
public static TSource FirstOrDefault <TSource>(this ReadOnlyMemory <TSource> source, Func <TSource, bool> predicate) { var aggregate = new FirstOrDefaultPredicate <TSource>(predicate); MemoryNode.ProcessMemory(source, ref aggregate); return(aggregate.GetResult()); }
public static TSource FirstOrDefault <TSource>(this TSource[] source, Func <TSource, bool> predicate) { var aggregate = new FirstOrDefaultPredicate <TSource>(predicate); ArrayNode.ProcessArray(source, ref aggregate); return(aggregate.GetResult()); }