Пример #1
0
 public bool MoveNext()
 {
     do
     {
         if (version != list.version)
         {
             throw new InvalidOperationException("Collection modified");
         }
         if (index > 0 &&
             (!default(T).Equals(Current))    // only works for values that are set, otherwise the index might be buried in the stack somewhere
             )
         {
             int freeIndex = list.freeIndices.Peek();
             if (freeIndex < index)
             {
                 list.freeIndices.Pop();
                 list[freeIndex] = list[index];
                 list.RemoveAt(index);
             }
         }
         index++;
         return(index < list.Count);
     } while (default(T).Equals(Current));
 }
Пример #2
0
 /// <summary>
 /// Accessing Current after RemoveCurrent may throw a NullReferenceException or return default(T).
 /// </summary>
 public void RemoveCurrent()
 {
     list.RemoveAt(index);
 }