예제 #1
0
        /// <summary> Insert after p.</summary>
        /// <param name="x">the item to insert.
        /// </param>
        /// <param name="p">the position prior to the newly inserted item.
        /// </param>
        public virtual void  insert(System.Object x, CursorListItr p)
        {
            if (p != null && p.current != 0)
            {
                int pos = p.current;
                var tmp = alloc();

                cursorSpace[tmp].element = x;
                cursorSpace[tmp].next    = cursorSpace[pos].next;
                cursorSpace[pos].next    = tmp;
            }
        }
예제 #2
0
        /// <summary> Remove the first occurrence of an item.</summary>
        /// <param name="x">the item to remove.
        /// </param>
        public virtual void  remove(System.Object x)
        {
            CursorListItr p   = findPrevious(x);
            int           pos = p.current;

            if (cursorSpace[pos].next != 0)
            {
                int tmp = cursorSpace[pos].next;
                cursorSpace[pos].next = cursorSpace[tmp].next;
                free(tmp);
            }
        }
예제 #3
0
        // Simple print method
        static public void  printList(CursorList theList)
        {
            if (theList.Empty)
            {
                System.Console.Out.Write("Empty list");
            }
            else
            {
                CursorListItr itr = theList.first();
                for (; !itr.PastEnd; itr.advance())
                {
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    System.Console.Out.Write(itr.retrieve() + " ");
                }
            }

            System.Console.Out.WriteLine();
        }