public bool MoveNext()
 {
     do
     {
         if (version != list.version)
         {
             throw new InvalidOperationException("Collection modified");
         }
         if (index > 0)
         {
             int freeIndex = list.freeIndices.Peek();
             if (freeIndex < index)
             {
                 list.freeIndices.Pop();
                 list[freeIndex] = list[index];
                 list.RemoveAt(index);
             }
         }
         index++;
         return(index < list.Count);
     } while (Current == null);
 }
Exemple #2
0
 public bool MoveNext()
 {
     do
     {
         if (version != list.version)
         {
             throw new InvalidOperationException("Collection modified");
         }
         if (index > 0 &&
             Current != null        // only works for values that are set, otherwise the index is buried in the free index 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 (Current == null);
 }
Exemple #3
0
 /// <summary>
 /// Accessing Current after RemoveCurrent may throw a NullReferenceException or return null.
 /// </summary>
 public void RemoveCurrent()
 {
     list.RemoveAt(index);
 }