public override object[] ToArray() { object[] array; lock (root) { array = deque.ToArray(); } return(array); }
public void ToArray() { var deque = new Deque<int>(); var array = deque.ToArray(); Assert.AreEqual(0, array.Length); deque = new Deque<int>(new[] { 2, 3, 4 }); array = deque.ToArray(); Assert.AreEqual(3, array.Length); Assert.AreEqual(2, array[0]); Assert.AreEqual(3, array[1]); Assert.AreEqual(4, array[2]); }
private static void TestToArray(Deque deque) { deque.Clear(); PopulateDequePushBack(deque); object[] array = deque.ToArray(); int i = 0; foreach(object obj in deque) { Debug.Assert(obj.Equals(array[i])); i++; } }