Example #1
0
 public void stringToCustomLinkedCharList(string manString)
 {
     manipulatedCustom.AddFirst(manString.ElementAt(0));
     head = manipulatedCustom.First;
     for (int i = 1; i < manString.Length; i++)
     {
         manipulatedCustom.AddAfter(head, manString.ElementAt(i));
         head = head.Next;
     }
 }
Example #2
0
        public void AddAfter(CNode <T> current, T cValue)
        {
            CNode <T> temp = new CNode <T>(cValue);
            CNode <T> temp2;

            temp2        = current.Next;
            current.Next = temp;
            temp.Next    = temp2;
            temp.Last    = current;
        }
Example #3
0
        public override string ToString()
        {
            string manString = null;

            head = manipulatedCustom.First;
            for (int i = 0; i < manipulatedCustom.Count(); i++)
            {
                manString += head.Value;
                head       = head.Next;
            }

            return(manString);
        }
Example #4
0
        public void AddFirst(T cValue)
        {
            CNode <T> temp = new CNode <T>(cValue);

            if (Head == null)
            {
                Head = temp;
            }
            while (Head.Last != null)
            {
                temp = temp.Last;
            }
            first = temp;
        }
Example #5
0
        public int Count()
        {
            int       count;
            int       loopcount  = 0;
            CNode <T> headholder = Head;

            for (int i = 0; headholder != null; i++)
            {
                headholder = headholder.Next;
                loopcount++;
            }
            count = loopcount;
            return(count);
        }
Example #6
0
        public void Insert(int startIndex, string stringToInsert)
        {
            int count = 0;

            head = manipulatedCustom.First;
            for (int i = 0; i < manipulatedCustom.Count(); i++)
            {
                if (i >= startIndex - 1 && count < stringToInsert.Length)
                {
                    manipulatedCustom.AddAfter(head, stringToInsert.ElementAt(count));
                    count++;
                }
                head = head.Next;
            }
        }
Example #7
0
        //public void addHead(T cValue)
        //{
        //    CNode<T> temp = new CNode<T>(cValue);
        //    temp.Next = head;
        //    head = temp;
        //}
        public void AddLast(T cValue)
        {
            CNode <T> temp = new CNode <T>(cValue);

            if (Head == null)
            {
                Head = temp;
            }
            else
            {
                while (Head.Next != null)
                {
                    temp = temp.Next;
                }
            }
            last = temp;
        }
Example #8
0
        public void Remove(int startIndex, int numCharsToRemove)
        {
            int count2 = 0;

            head = manipulatedCustom.First;
            for (int i = 0; i < manipulatedCustom.Count(); i++)
            {
                CNode <char> next;
                next = head.Next;
                while (i >= startIndex - 1 && count2 < numCharsToRemove)
                {
                    CNode <char> nextNext;
                    nextNext = next.Next;
                    manipulatedCustom.Remove(next);
                    next = nextNext;
                    count2++;
                }
                head = head.Next;
            }
        }
Example #9
0
 public CNode(T CValue)
 {
     cValue = CValue;
     next   = null;
     last   = null;
 }
Example #10
0
 public void Remove(CNode <T> current)
 {
     current.Next.Last = current.Last;
     current.Last.Next = current.Next;
     current           = null;
 }
Example #11
0
 public CustomLinkedList()
 {
     Head = null;
 }