public static int Count <T>(this System.Collections.Generic.IEnumerable <T> e, System.Predicate <T> m = null) { if (e.IsNull()) { throw new System.NullReferenceException(); } var result = 0; var list = new System.Collections.Generic.List <T>(e); if (m.IsNull()) { result = list.Count; } else { for (var i = 0; i < list.Count; i++) { if (m.Invoke(list[i])) { result++; } } } list.Clear(); return(result); }
public static System.Collections.Generic.IList <T> ToList <T>(this System.Collections.Generic.IEnumerable <T> e) { if (e.IsNull()) { throw new System.NullReferenceException(); } return(new System.Collections.Generic.List <T>(e)); }
public static T Find <T>(this System.Collections.Generic.IEnumerable <T> e, System.Predicate <T> m = null) { if (e.IsNull()) { throw new System.NullReferenceException(); } var list = new System.Collections.Generic.List <T>(e); var result = list.Find(m); list.Clear(); return(result); }
public static T[] ToArray <T>(this System.Collections.Generic.IEnumerable <T> e) { if (e.IsNull()) { throw new System.NullReferenceException(); } var list = new System.Collections.Generic.List <T>(e); var result = list.ToArray(); list.Clear(); return(result); }
public static TOutput[] Convert <TInput, TOutput>(this System.Collections.Generic.IEnumerable <TInput> e, System.Converter <TInput, TOutput> c) { if (e.IsNull()) { throw new System.NullReferenceException(); } var list = new System.Collections.Generic.List <TInput>(e); var converted = list.ConvertAll(c); var result = converted.ToArray(); list.Clear(); converted.Clear(); return(result); }
public static bool Contains <T>(this System.Collections.Generic.IEnumerable <T> e, System.Predicate <T> m = null) { if (e.IsNull()) { throw new System.NullReferenceException(); } var list = new System.Collections.Generic.List <T>(e); var result = false; for (var i = 0; (i < list.Count) && !result; i++) { result = m.Invoke(list[i]); } list.Clear(); return(result); }