Custom collections
-
Hi! The .NET collection classes have me pissed off. Being a C++ kinda guy, I love linked lists and I find the dynamic arrays to be really inane. So, I'm creating my own linked list class. I'm having some trouble with the enumerator: An IEnumerator interface to an IEnumerable object is valid so long as IEnumerable wasn't modified after IEnumerator was created. How do I let my IEnumerator class know that my IEnumerable was modified? I don't want to use a DateTime/TimeSpan class. I was thinking of incrementing an integer everytime the list is modified and making that the hash code. the IEnumerator could store the hashcode when it was created and compare it to the current hashcode. However, with extensive use, this procedure may not work. Any suggestions?
-
Hi! The .NET collection classes have me pissed off. Being a C++ kinda guy, I love linked lists and I find the dynamic arrays to be really inane. So, I'm creating my own linked list class. I'm having some trouble with the enumerator: An IEnumerator interface to an IEnumerable object is valid so long as IEnumerable wasn't modified after IEnumerator was created. How do I let my IEnumerator class know that my IEnumerable was modified? I don't want to use a DateTime/TimeSpan class. I was thinking of incrementing an integer everytime the list is modified and making that the hash code. the IEnumerator could store the hashcode when it was created and compare it to the current hashcode. However, with extensive use, this procedure may not work. Any suggestions?
Refer to Nish's excellent article on implementing collections in MC++. He uses one possible solution (flag to say if it is modified). James "Java is free - and worth every penny." - Christian Graus