Пример #1
0
 public void addCommand(Command c)
 {
     if (c.next == null)
     {
         c.prev = null;
         c.setTime(c.getTimeOffset() + TimerManager.instance.getCurrentTime());
         if (command == null)
         {
             command = c;
         }
         else
         {
             //c.setTime(c.getTimeOffset()+ TimerManager.instance.getCurrentTime());
             Command temp = command;
             if (command.getTime() > c.getTime())
             {
                 c.next       = command;
                 command.prev = c;
                 command      = c;
                 command.prev = null;
             }
             else
             {
                 while (temp.getTime() <= c.getTime() && temp.next != null)
                 {
                     temp = temp.next;
                 }
                 if (temp.getTime() <= c.getTime())
                 {
                     temp.next = c;
                     c.prev    = temp;
                 }
                 else
                 {
                     c.prev = temp.prev;
                     c.next = temp;
                     if (c.prev != null)
                     {
                         c.prev.next = c;
                     }
                     temp.prev = c;
                 }
             }
         }
     }
 }
Пример #2
0
        public void execute()
        {
            Command temp = command;

            while (command != null && command.getTime() < TimerManager.instance.getCurrentTime())
            {
                command = command.next;
                if (temp.next != null)
                {
                    temp.next.prev = null;
                }
                else
                {
                    command = null;
                }
                temp.next = null;
                temp.prev = null;
                temp.execute();
                temp = command;
            }
        }