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); }
public object Clone() { IntDeQueue temp = new IntDeQueue(size - 1); temp.start = start; temp.end = end; data.CopyTo(temp.data, 0); return temp; }
public object Clone() { IntDeQueue temp = new IntDeQueue(size - 1); temp.start = start; temp.end = end; data.CopyTo(temp.data, 0); return(temp); }
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; }
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); }
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; }