예제 #1
0
        public static void Start(string list, int rotationPoint)
        {
            var head = new DoubleNode(list);

            Console.Write($"Original List: ");
            head.Print();
            var rotatedList = Rotate(head, rotationPoint);

            Console.Write($"Rotated List: ");
            rotatedList.Print();
        }
예제 #2
0
        private void CreateListFromString(string numbers)
        {
            var numbersArray = numbers.Split(' ').Select(numberStr => int.Parse(numberStr)).ToList();

            Data = numbersArray[0];
            DoubleNode currentNode = this;

            for (int iterator = 1; iterator < numbersArray.Count; iterator++)
            {
                var node = new DoubleNode(numbersArray[iterator]);
                currentNode.Next = node;
                node.Prev        = currentNode;
                currentNode      = currentNode.Next;
            }
        }
예제 #3
0
 public DoubleNode(int data)
 {
     Data = data;
     Prev = null;
     Next = null;
 }