* HashSet.cs (Enumerator.IEnumerator.Reset): Check invariants.
[mono.git] / mcs / class / System.Core / System.Collections.Generic / HashSet.cs
index 56fc575c1837542cc39ec54974c6bcbb2c65c383..91c5a5c15f1c845e2cd0a0e19264c1e11413659c 100644 (file)
@@ -612,13 +612,16 @@ namespace System.Collections.Generic {
 
                        object IEnumerator.Current {
                                get {
-                                       CheckCurrent ();
+                                       CheckState ();
+                                       if (next <= 0)
+                                               throw new InvalidOperationException ("Current is not valid");
                                        return current;
                                }
                        }
 
                        void IEnumerator.Reset ()
                        {
+                               CheckState ();
                                next = 0;
                        }
 
@@ -634,14 +637,6 @@ namespace System.Collections.Generic {
                                if (hashset.generation != stamp)
                                        throw new InvalidOperationException ("HashSet have been modified while it was iterated over");
                        }
-
-                       void CheckCurrent ()
-                       {
-                               CheckState ();
-
-                               if (next <= 0)
-                                       throw new InvalidOperationException ("Current is not valid");
-                       }
                }
 
                // borrowed from System.Collections.HashTable