Ejemplo n.º 1
0
 private void SetHead(T data)
 {
     Head          = new CircleListNode <T>(data);
     Head.Next     = Head;
     Head.Previous = Head;
     Count++;
 }
Ejemplo n.º 2
0
 public void RemoveItem(CircleListNode <T> current)
 {
     current.Next.Previous = current.Previous;
     current.Previous.Next = current.Next;
     if (current.Equals(Head))
     {
         Head = Head.Next;
     }
     Count--;
 }
Ejemplo n.º 3
0
        public CircleListNode <T> GetByIndex(int index)
        {
            var result  = new CircleListNode <T>();
            var current = Head;

            for (int i = 0; i < Count; i++)
            {
                if (i == index)
                {
                    result = current;
                    break;
                }
                current = current.Next;
            }
            return(result);
        }
Ejemplo n.º 4
0
 public void Add(T data)
 {
     if (Head == null)
     {
         SetHead(data);
         return;
     }
     else
     {
         var current = new CircleListNode <T>(data);
         current.Next       = Head;
         current.Previous   = Head.Previous;
         Head.Previous.Next = current;
         Head.Previous      = current;
         Count++;
     }
 }