public PythonDequeEnumerator(PythonDequeCollection d) { lock (d.lockObj) { deque = d; curIndex = d.head - 1; version = d.version; } }
public object Copy() { if (GetType() == typeof(PythonDequeCollection)) { PythonDequeCollection res = new PythonDequeCollection(); res.Extend(this.GetEnumerator()); return(res); } else { UserType ut = Ops.GetDynamicType(this) as UserType; System.Diagnostics.Debug.Assert(ut != null); return(ut.Call(new object[] { GetEnumerator() })); } }
public object Copy() { if (GetType() == typeof(PythonDequeCollection)) { PythonDequeCollection res = new PythonDequeCollection(); res.Extend(this.GetEnumerator()); return res; } else { return Ops.Call(Ops.GetDynamicType(this), GetEnumerator()); } }
public int CompareTo(object obj) { PythonDequeCollection otherDeque = obj as PythonDequeCollection; if (otherDeque == null) { throw new ArgumentException("expected deque"); } if (otherDeque.itemCnt == 0 && itemCnt == 0) { // comparing two empty deques return(0); } ArrayList infinite = Ops.GetCmpInfinite(); if (infinite.Contains(this)) { return(0); } int index = infinite.Add(this); try { int otherIndex = otherDeque.head, ourIndex = head; for (; ;) { int result = Ops.Compare(data[ourIndex], otherDeque.data[otherIndex]); if (result != 0) { return(result); } // advance both indexes otherIndex++; if (otherIndex == otherDeque.data.Length) { otherIndex = 0; } else if (otherIndex == otherDeque.tail) { break; } ourIndex++; if (ourIndex == data.Length) { ourIndex = 0; } else if (ourIndex == tail) { break; } } // all items are equal, but # of items may be different. if (otherDeque.itemCnt == itemCnt) { // same # of items, all items are equal return(0); } return(itemCnt > otherDeque.itemCnt ? 1 : -1); } finally { System.Diagnostics.Debug.Assert(infinite.Count == index + 1); infinite.RemoveAt(index); } }