Beispiel #1
0
 internal Chained(T current, Chained <T> previous)
 {
     Value = current;
     if (previous != null)
     {
         previous.Next = this;
     }
 }
Beispiel #2
0
        internal Chained <TTarget> MapFilter <TTarget>(Func <T, TTarget> transform, Predicate <TTarget> filter = null)
        {
            filter = filter ?? True <TTarget>;
            var current          = this;
            var result           = default(Chained <TTarget>);
            var currentTransform = default(Chained <TTarget>);

            while (current != null)
            {
                var target = transform(current.Value);
                if (filter(target))
                {
                    currentTransform = new Chained <TTarget>(target, currentTransform);
                    result           = result ?? currentTransform;
                }
                current = current.Next;
            }

            return(result);
        }