private void CheckDeque(IDeque <Type> c)
 {
     builder.ExpectThat(c.Peek(), Is.Null);
     builder.ExpectException <InvalidOperationException> (() => c.Dequeue());
     if (c.ToArray() != null)
     {
         builder.ExpectThat(c.ToArray().Length, Is.EqualTo(0));
     }
     builder.ExpectThat(c.GetEnumerator().MoveNext(), Is.False);
     builder.ExpectThat(c.GetDescendingEnumerator().MoveNext(), Is.False);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the value from the dictionary or list or deque at the nth position as defined by the iterator of the dictionary or the index of the list or the iterator of the deque.
 /// </summary>
 /// <param name="obj">A dictionary or a list or a deque.</param>
 /// <param name="num">The number of the element to get in the iteration sequence.</param>
 /// <returns>The element at the position to get.</returns>
 public static object Peek(object obj, int num)
 {
     if (obj is IDictionary)
     {
         IDictionary           dict = (IDictionary)obj;
         IDictionaryEnumerator it   = dict.GetEnumerator();
         if (num >= 0)
         {
             it.MoveNext();
         }
         for (int i = 0; i < num; ++i)
         {
             it.MoveNext();
         }
         return(it.Key);
     }
     else if (obj is IList)
     {
         IList list = (IList)obj;
         return(list[num]);
     }
     else
     {
         IDeque deque = (IDeque)obj;
         if (num == 0)
         {
             return(deque.Front);
         }
         IEnumerator it = deque.GetEnumerator();
         if (num >= 0)
         {
             it.MoveNext();
         }
         for (int i = 0; i < num; ++i)
         {
             it.MoveNext();
         }
         return(it.Current);
     }
 }
Ejemplo n.º 3
0
 public IEnumerator <T> GetEnumerator()
 {
     return(dq.GetEnumerator());
 }
Ejemplo n.º 4
0
 /// <inheritdoc />
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(_deque.GetEnumerator());
 }