예제 #1
0
        public static IEnumerable <LinkedListNode <T> > GetRangeNodes <T>(this LinkedListNode <T> start, int offset)
        {
            if (offset == 0)
            {
                return(new[] { start });
            }

            List <LinkedListNode <T> > buffer = new List <LinkedListNode <T> >();

            int step = offset < 0 ? -1 : 1;

            for (int i = 0; offset <0 ? i> offset : i < offset; i += step)
            {
                buffer.Add(start.GetAtOffset(i));
            }

            return(offset < 0 ? buffer.AsEnumerable().Reverse() : buffer);
        }