Exemplo n.º 1
0
        // add element to end with value value.
        public void AddElement(ElementType value)
        {
            if (head == null)
            {
                head = new ListElement(value, null);
                return;
            }
            ListElement temp = head;

            for (temp = head; temp.Next() != null; temp = temp.Next())
            {
                ;
            }
            temp.AddListElement(value);
        }
Exemplo n.º 2
0
        // add element after position pos.
        public void AddElementToPosition(ElementType value, Position pos)
        {
            if (head == null)
            {
                head = new ListElement(value, null);
                return;
            }
            if (pos == 0)
            {
                AddElementToHead(value);
                return;
            }
            ListElement temp = head;
            int         i    = 0;

            for (i = 0; temp.Next() != null && i != pos - 1; temp = temp.Next(), i++)
            {
                ;
            }
            temp.AddListElement(value);
        }