public void Remove(T Data)
 {
     while (Head != null && Head.Data.Equals(Data))
     {
         if (Count == 1)
         {
             Head = null;
         }
         LinkedListNode_1side <T> c = Head;
         while (c.Next != Head)
         {
             c = c.Next;
         }
         Head   = Head.Next;
         c.Next = Head;
         Count--;
     }
     if (Head != null && Count != 1)
     {
         for (LinkedListNode_1side <T> c = Head; c.Next != Head;)
         {
             if (c.Next.Data.Equals(Data))
             {
                 c.Next = c.Next.Next;
                 Count--;
             }
             else
             {
                 c = c.Next;
             }
         }
     }
 }
Exemple #2
0
        public T At(int Index)
        {
            int Counter = 1;

            for (LinkedListNode_1side <T> c = Head; c != null; c = c.Next, Counter++)
            {
                if (Counter == Index)
                {
                    return(c.Data);
                }
            }
            return(default(T));
        }
        public T At(int Index)
        {
            if (Index == 1)
            {
                return(Head.Data);
            }
            int Counter = 2;

            for (LinkedListNode_1side <T> c = Head.Next; c != Head; c = c.Next, Counter++)
            {
                if (Counter == Index)
                {
                    return(c.Data);
                }
            }
            return(default(T));
        }
Exemple #4
0
        public void Add(T Data)
        {
            LinkedListNode_1side <T> New = new LinkedListNode_1side <T>()
            {
                Data = Data
            };

            if (Head == null)
            {
                Head = New;
            }
            else
            {
                var c = Head;
                while (c.Next != null)
                {
                    c = c.Next;
                }
                c.Next = New;
            }
            Count++;
        }