示例#1
0
        //done
        public override void Add(T data, int Position)
        {
            Node NewNode = new RoverListBase <T> .Node(data);

            if (Position == 0)
            {
                NewNode.Next = RootNode;
                RootNode     = NewNode;
            }
            else
            {
                Node LeftNode  = GetNode(Position - 1);
                Node RightNode = GetNode(Position);
                LeftNode.Next = NewNode;
                NewNode.Next  = RightNode;
            }
        }
示例#2
0
        public override void Add(T data)
        {
            Node newNode = new RoverListBase <T> .Node(data, null);

            if (head == null)
            {
                head    = newNode;
                current = head;
            }

            else
            {
                current.Next = newNode;
                current      = current.Next;
            }

            count++;
        }
示例#3
0
        // public override int Count => throw new NotImplementedException();

        public override void Add(T data)
        {
            Node newNode = new RoverListBase <T> .Node(data, null);


            if (head == null)
            {
                head    = newNode;
                current = head;
            }
            else
            {
                //traverse the list until you get to the end
                current.Next = newNode;
                current      = current.Next;
            }
            count++;
            // throw new NotImplementedException();
        }
示例#4
0
        public override void Add(int Position, T data)
        {
            Node newNode = new RoverListBase <T> .Node(data, null);

            var temp          = head;
            int internalCount = 0;


            if (head == null)
            {
                head    = newNode;
                current = head;
            }

            if (Position == 0)
            {
                var temp3 = head;
                head      = newNode;
                head.Next = temp3;
            }


            else
            {
                while (internalCount != Position - 1)
                {
                    temp = temp.Next;
                    internalCount++;
                }



                var temp2 = temp.Next;
                temp.Next = newNode;
                temp      = temp.Next;
                temp.Next = temp2;
            }

            count++;
        }