示例#1
0
        static public int RunLists()
        {
            IntDeQueue q = new IntDeQueue(SIZE);

            for (int i = 0; i < SIZE; ++i)
            {
                q.PushBack(i + 1);
            }
            IntDeQueue q2 = (IntDeQueue)q.Clone();
            IntDeQueue q3 = new IntDeQueue(SIZE);

            while (!q2.Empty)
            {
                q3.PushBack(q2.PopFront());
            }
            while (!q3.Empty)
            {
                q2.PushBack(q3.PopBack());
            }
            q.Reverse();
            if (q.PeekFront() != SIZE)
            {
                return(-1);
            }
            if (!q.Equals(q2))
            {
                return(-1);
            }

            return(q.Count);
        }
示例#2
0
 public object Clone()
 {
     IntDeQueue temp = new IntDeQueue(size - 1);
     temp.start = start;
     temp.end = end;
     data.CopyTo(temp.data, 0);
     return temp;
 }
示例#3
0
            public object Clone()
            {
                IntDeQueue temp = new IntDeQueue(size - 1);

                temp.start = start;
                temp.end   = end;
                data.CopyTo(temp.data, 0);
                return(temp);
            }
示例#4
0
 public bool Equals(IntDeQueue other)
 {
     if (Count != other.Count)
         return false;
     int i = this.start;
     int iOther = other.start;
     while (i != this.end)
     {
         if (data[i] != other.data[iOther])
             return false;
         Advance(ref i);
         other.Advance(ref iOther);
     }
     return true;
 }
示例#5
0
            public bool Equals(IntDeQueue other)
            {
                if (Count != other.Count)
                {
                    return(false);
                }
                int i      = this.start;
                int iOther = other.start;

                while (i != this.end)
                {
                    if (data[i] != other.data[iOther])
                    {
                        return(false);
                    }
                    Advance(ref i);
                    other.Advance(ref iOther);
                }
                return(true);
            }
示例#6
0
        static public int RunLists()
        {
            IntDeQueue q = new IntDeQueue(SIZE);
            for (int i = 0; i < SIZE; ++i)
                q.PushBack(i + 1);
            IntDeQueue q2 = (IntDeQueue)q.Clone();
            IntDeQueue q3 = new IntDeQueue(SIZE);
            while (!q2.Empty)
                q3.PushBack(q2.PopFront());
            while (!q3.Empty)
                q2.PushBack(q3.PopBack());
            q.Reverse();
            if (q.PeekFront() != SIZE)
            {
                return (-1);
            }
            if (!q.Equals(q2))
            {
                return (-1);
            }

            return q.Count;
        }