Example #1
0
        public static IReadOnlyList <TResult> ToList <TSource, TResult>(this NodeArray.NodeArraySelectorEnumerable <TSource, TResult>?selectEnumerable)
        {
            if (selectEnumerable == null)
            {
                return(CollectionUtilities.EmptyArray <TResult>());
            }

            return(ToList(selectEnumerable.Value));
        }
Example #2
0
        public static IReadOnlyList <TResult> ToList <TSource, TResult>(this NodeArray.NodeArraySelectorEnumerable <TSource, TResult> selectEnumerable)
        {
            var result = new List <TResult>(selectEnumerable.ArraySize);

            foreach (var e in selectEnumerable)
            {
                result.Add(e);
            }

            return(result);
        }
Example #3
0
        /// <nodoc />
        public static TResult FirstOrDefault <TSource, TResult>(this NodeArray.NodeArraySelectorEnumerable <TSource, TResult> selectEnumerable, Func <TResult, bool> predicate)
        {
            foreach (var e in selectEnumerable)
            {
                var predicateResult = predicate(e);
                if (predicateResult)
                {
                    return(e);
                }
            }

            return(default(TResult));
        }
Example #4
0
        /// <nodoc />
        public static IEnumerable <TResult> Where <TSource, TResult>(this NodeArray.NodeArraySelectorEnumerable <TSource, TResult> selectEnumerable, Func <TResult, bool> predicate)
        {
            // If the array is empty it make no sense to allocate anything.
            if (selectEnumerable.ArraySize == 0)
            {
                return(CollectionUtilities.EmptyArray <TResult>());
            }

            return(Where());

            IEnumerable <TResult> Where()
            {
                foreach (var e in selectEnumerable)
                {
                    if (predicate(e))
                    {
                        yield return(e);
                    }
                }
            }
        }