Tue, 17 Jul 2001 01:12:53 -0700
This article suggests the same approach and actually claims that this is how
Microsoft does it:
Personally, the chance for one error for every 4 billion modifications seems
acceptable to me.
> -----Original Message-----
> From: firstname.lastname@example.org [mailto:email@example.com]On
> Behalf Of David Menestrina
> Sent: Tuesday, July 17, 2001 12:52 AM
> To: firstname.lastname@example.org
> Subject: [Mono-list] IEnumerators
> IEnumerator.MoveNext() has to throw
> InvalidOperationException if the object it's
> enumerating is modified in any way. I tested this
> with MS's implementation of BitArray, and it seems to
> really detect *any* change to the original object.
> Maybe my brain is fried, but I can't seem to think
> of a great way to implement this. The best way I can
> think of is to have the original object keep a change
> count. Whenever any call modifies the object,
> increment the count. The IEnumerator will store
> the value on creation, then check it every time you
> call MoveNext().
> This works in all cases except when you modify
> something 4 billion times before calling MoveNext.
> Does anyone have a cleaner idea? I can't keep
> to all the IEnumerators, because then they'd never
> get GC'ed.
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> Mono-list maillist - Monoemail@example.com