예제 #1
0
파일: List.cs 프로젝트: 0x0all/MyProgram
        // 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);
        }
예제 #2
0
파일: List.cs 프로젝트: 0x0all/MyProgram
        // 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);
        }