Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 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);
                    }
                }
            }
        }