public void Remove(int startIndex, int numCharsToRemove)
        {
            if (startIndex < 0)
            {
                throw new ArgumentOutOfRangeException("index: " + startIndex);
            }
            if (this.ZeroCountProp)
            {
                //return null;
            }
            if (startIndex >= this.listCount)
            {
                startIndex = listCount - 1;
            }
            Node current = this.headNode;
            object result = null;
            

            if (startIndex == 0)
            {
                result = current.DataProp;
                this.headNode = current.NextProp;
            }
            else
            {
                for (int i = 0; i < startIndex - 1; i++)
                {
                    current = current.NextProp;
                }
                result = current.NextProp.DataProp;
                current.NextProp = current.NextProp.NextProp;
            }
            listCount--;
            
        }
 public object AddToSpecifiedIndex(int index, object listItemToAdd)
 {
     if (index < 0 )
     {
         throw new ArgumentOutOfRangeException("index: " + index);
     }
     if (index > listCount)
     {
         index = listCount;
     }
     Node current = this.headNode;
     if (this.ZeroCountProp || index == 0)
     {
         this.headNode = new Node(listItemToAdd, this.headNode);
     }
     else
     {
         for (int i = 0; i < index - 1; i++)
         {
             current = current.NextProp;
         }
         current.NextProp = new Node(listItemToAdd, current.NextProp);
     }
     listCount++;
     return listItemToAdd;
 }
 public void ClearList()
 {
     this.headNode = null;
     this.listCount = 0;
 }
 public CustomLinkedListString()
 {
     this.headNode = null;
     this.listCount = 0;
 }
예제 #5
0
 public Node(object data, Node next)
 {
     this.nodeData = data;
     this.nextNode = next;
 }