public override void PushBack(object obj) { lock (root) { deque.PushBack(obj); } }
private static void PopulateDequePushBack(Deque deque) { deque.Clear(); for(int i = 0; i < ElementCount; i++) { deque.PushBack(i); } Debug.Assert(deque.Count == ElementCount); int j = 0; foreach(int i in deque) { Debug.Assert(i == j); j++; } }
private static void TestEnumerator(Deque deque) { deque.Clear(); PopulateDequePushBack(deque); IEnumerator e = deque.GetEnumerator(); try { object obj = e.Current; Debug.Fail("Exception failed"); } catch(Exception ex) { Console.WriteLine(ex.Message); } try { foreach(object obj in deque) { Debug.Assert(e.MoveNext()); } Debug.Assert(!e.MoveNext()); object o = e.Current; Debug.Fail("Exception failed"); } catch(Exception ex) { Console.WriteLine(ex.Message); } try { e.Reset(); foreach(object obj in deque) { Debug.Assert(e.MoveNext()); } Debug.Assert(!e.MoveNext()); object o = e.Current; Debug.Fail("Exception failed"); } catch(Exception ex) { Console.WriteLine(ex.Message); } try { deque.PushBack(deque.Count); e.Reset(); Debug.Fail("Exception failed"); } catch(Exception ex) { Console.WriteLine(ex.Message); } try { e.MoveNext(); Debug.Fail("Exception failed"); } catch(Exception ex) { Console.WriteLine(ex.Message); } }