Example #1
0
 public DoubleCircularList(T item)
 {
     m_header = new DoubleNode <T>(item);
     current  = new DoubleNode <T>();
     newNode  = new DoubleNode <T>();
     m_header.SetNext(m_header);
     m_header.SetPrev(m_header);
 }
        /// <summary>
        /// Insert used to add an Item anywhere into the list after any given value
        /// </summary>
        /// <param name="newItem">New Item being added into the linked list</param>
        /// <param name="after">After this value the new Item will be added</param>
        public void Insert(T newItem, T after)
        {
            newNode = new DoubleNode<T>(newItem);

            current = Find(after);
            newNode.SetNext(current.GetNext());
            newNode.SetPrev(current);
            current.SetNext(newNode);
        }
 /// <summary>
 /// This method will remove the given Item from the list and ajust all links
 /// </summary>
 /// <param name="Item">Item to be removed</param>
 public void Remove(T Item)
 {
     DoubleNode<T> p = Find(Item);
     if (!(current.GetNext() == null))
     {
         p.GetPrev().SetNext(p.GetNext());
         p.GetNext().SetPrev(p.GetPrev());
         p.SetNext(null);
         p.SetPrev(null);
     }
 }
Example #4
0
        /// <summary>
        /// This method will remove the given Item from the list and ajust all links
        /// </summary>
        /// <param name="Item">Item to be removed</param>
        public void Remove(T Item)
        {
            DoubleNode <T> p = FindPrevious(Item);

            if (!(p.GetNext() == m_header))
            {
                p.GetPrev().SetNext(p.GetNext());
                p.GetNext().SetPrev(p.GetPrev());
                p.SetNext(null);
                p.SetPrev(null);
            }
        }
        /// <summary>
        /// Method used to add node to end of the linked list
        /// </summary>
        /// <param name="newItem">The Item being added to the end of the linked list</param>
        public void AddToEnd(T newItem)
        {
            current = m_header;
            newNode = new DoubleNode<T>(newItem);

            while (!(current.GetNext() == null))
            {
                current = current.GetNext();
            }

            current.SetNext(newNode);
            newNode.SetPrev(current);
        }
Example #6
0
 /// <summary>
 /// This method will make the circular listt completly emply
 /// </summary>
 public void MakeEmpty()
 {
     m_header.SetNext(m_header);
     m_header.SetPrev(m_header);
 }