[Mono-list] ArrayList Enumerator
John Barnette
jbarn@httcb.net
Mon, 5 Nov 2001 22:24:24 -0600
Nick,
If by 'robust' you mean that modification of an underlying container should
not invalidate extant iterators, I'm not certain it's a good idea.
Consistent behavior over different types of containers is important for
iterators, and while one could certainly recover from modifications to, say,
a read-only queue, it's one of many cases.
Not to resort to the lame and tired 'this is the way everybody does it'
argument, but, well, this is the way everybody does it. ;-) It's similar in
the Java libraries, and, as I recall, it was similar in the NeXT libs.
For an example of this sort of iterator, check out my
System.Collections.Specialized.ListDictionary.
~ j.
----- Original Message -----
From: "Nick Drochak" <ndrochak@gol.com>
To: "Mono-List" <mono-list@ximian.com>
Cc: "John Barnette" <jbarn@httcb.net>
Sent: Monday, November 05, 2001 8:56 PM
Subject: RE: [Mono-list] ArrayList Enumerator
> | Apologies if this is redundant information; I'm away from my
> | normal network
> | connection. It might be worth noting that the 'standard' way to
> | do this for
> | mutable containers seems to be a modification count / version on the
> | container. When an iterator is created, it's assigned a version. When
> | methods are called on the iterator, they only succeed if
> | collection.modCount
> | == iterator.modCount.
> |
>
> Redundant, but helpful :)
>
> Can you point me to any good resources for mutable container/iterator
> design? There seems to be quite a bit of work in the area of making the
> iterators "robust" when the container is mutated. However, the .NET
> ArrayList design just takes the simple approach of making the enumerator
> (iterator) invalid.
>
> Thanks,
> Nick D.
>