Esempio n. 1
0
 //  Search given shape and set current to it if found
 public bool Search(AShape s)
 {
     if (s != null)
     {
         DoublyNode t = current;
         Set_current_first();
         for (bool cond = !Is_empty(); cond;
              cond = Step_forward())
         {
             if (Current.Shape == s)
             {
                 return(true);
             }
         }
         current = t;
     }
     Notify();
     return(false);
 }
Esempio n. 2
0
        //  Add new shape to the front of the list
        public bool Push_front(AShape shape)
        {
            if (shape == null)
            {
                return(false);
            }
            DoublyNode fresh = new DoublyNode(shape);

            if (count > 0)
            {
                head.prev  = fresh;
                fresh.next = head;
                head       = fresh;
            }
            else
            {
                tail = fresh;
                head = fresh;
            }
            current = head;
            ++count;
            Notify();
            return(true);
        }
Esempio n. 3
0
        //  Add new shape to the back of the list
        public bool Push_back(AShape shape)
        {
            if (shape == null)
            {
                return(false);
            }
            DoublyNode fresh = new DoublyNode(shape);

            if (count > 0)
            {
                fresh.prev = tail;
                tail.next  = fresh;
                tail       = fresh;
            }
            else
            {
                tail = fresh;
                head = fresh;
            }
            current = tail;
            ++count;
            Notify();
            return(true);
        }
Esempio n. 4
0
 public DoublyNode(AShape shape)
 {
     this.shape = shape;
     prev       = null;
     next       = null;
 }