コード例 #1
0
        public static void sol_cmd_enq_deferred()
        {
            CLRList l;
            CLRList r;

            /* Reverse the list to preserve original command order. */

            for (r = null, l = deferred_cmds;
                 l != null;
                 r = CLRList.list_cons(l.data, r), l = CLRList.list_rest(l))
            {
                ;
            }

            /* Enqueue commands. */

            for (; r != null; r = CLRList.list_rest(r))
            {
                if (enq_fn.cmd_enq_fn != null)
                {
                    enq_fn.cmd_enq_fn.func((Command)r.data);
                }

                r.data = null;
            }

            deferred_cmds = null;
        }
コード例 #2
0
ファイル: Queue.cs プロジェクト: supeindesu/Neverball.NET
        public static void queue_enq(CLRQueue q, object data)
        {
            q.tail.data = data;
            q.tail.next = CLRList.list_cons((object)null, null);

            q.tail = q.tail.next;
        }
コード例 #3
0
        /*
         * Free the list cell FIRST and return the "next" member. The "data"
         * member is not freed.
         */
        public static CLRList list_rest(CLRList first)
        {
            CLRList rest = first.next;

            first = null;

            return(rest);
        }
コード例 #4
0
        public static void sol_cmd_enq(Command lnew)
        {
            if (defer_cmds != 0)
            {
                Command copy;
                CLRList l;
                CLRList p;

                for (p = null, l = deferred_cmds; l != null; p = l, l = l.next)
                {
                    Command cur = (Command)l.data;

                    /* Remove element made obsolete by the lnew command. */

                    if (lnew.type == cur.type &&
                        ((lnew.type == cmd_type.CMD_BODY_TIME &&
                          lnew.bodytime.bi == cur.bodytime.bi) ||
                         (lnew.type == cmd_type.CMD_BODY_PATH &&
                          lnew.bodypath.bi == cur.bodypath.bi)))
                    {
                        //free(cur);
                        cur = null;

                        if (p != null)
                        {
                            p.next = CLRList.list_rest(l);
                        }
                        else
                        {
                            deferred_cmds = CLRList.list_rest(l);
                        }

                        /*
                         * The operation above made the list pointer useless
                         * for the variable update part of the loop, and it
                         * seems a bit involved to recover from that in a
                         * proper fashion.  Fortunately, this very block
                         * ensures that there's only one element to remove, so
                         * no more iterations are needed.
                         */

                        l = null;
                        break;
                    }
                }

                copy = new Command();
                {
                    copy.CopyFrom(lnew);
                    deferred_cmds = CLRList.list_cons(copy, deferred_cmds);
                }
            }
            else if (enq_fn.cmd_enq_fn != null)
            {
                enq_fn.cmd_enq_fn.func(lnew);
            }
        }
コード例 #5
0
ファイル: Queue.cs プロジェクト: supeindesu/Neverball.NET
        public static CLRQueue CLR_queue_new()
        {
            CLRQueue lnew;

            lnew      = new CLRQueue();
            lnew.head = lnew.tail = CLRList.list_cons((object)null, null);

            return(lnew);
        }
コード例 #6
0
        /*
         * Allocate and return a list cell initialised with FIRST and REST as
         * "data" and "next" members, respectively.
         */
        public static CLRList list_cons(object first, CLRList rest)
        {
            CLRList lnew;

            lnew = new CLRList();
            {
                lnew.data = first;
                lnew.next = rest;
            }

            return(lnew);
        }
コード例 #7
0
ファイル: Queue.cs プロジェクト: supeindesu/Neverball.NET
        public static object queue_deq(CLRQueue q)
        {
            object data = null;

            if (queue_empty(q) == 0)
            {
                data   = q.head.data;
                q.head = CLRList.list_rest(q.head);
            }

            return(data);
        }
コード例 #8
0
 public CLRList()
 {
     data = null;
     next = null;
 }
コード例 #9
0
ファイル: Queue.cs プロジェクト: supeindesu/Neverball.NET
 public CLRQueue()
 {
     head = null;
     tail = null;
 }