コード例 #1
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);
 }
コード例 #2
0
 /// <summary>
 /// Accessing Current after RemoveCurrent may throw a NullReferenceException or return null.
 /// </summary>
 public void RemoveCurrent()
 {
     list.RemoveAt(index);
 }