tag:blogger.com,1999:blog-367223172444482925.post202404883578887639..comments2010-09-12T07:18:08.592-07:00Comments on CoderPaws: Working With ArrayList: What is the best Iterator choice?Coder Pawshttp://www.blogger.com/profile/13363735036769185632noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-367223172444482925.post-29246040447767879802010-09-12T07:18:08.592-07:002010-09-12T07:18:08.592-07:00I meant you should have a separate queue/stack for...I meant you should have a separate queue/stack for incoming data.<br /><br />You're not looping through this queue/stack though. Instead, you remove an item from the queue/stack (queue.Dequeue/stack.Pop). Whatever in the queue/stack is not processed. The processed data can be saved in whatever list you want.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-367223172444482925.post-88399757162236441222010-09-11T17:48:22.630-07:002010-09-11T17:48:22.630-07:00Van, Thank you for your comment. My point exactly...Van, Thank you for your comment. My point exactly, as I discovered, is that foreach requires no changes to the collection...period. Looking at various forums, it appeared to be a common question of how to deal with it.<br /><br />For my application, ArrayList seemed to fit best with the tools that I have thusfar, remembering that I'm still learning. I attempted to build some robustness around the core issue of IEnumerable. I believe though that queue is also a System.Collection class that uses IEnumerable. Therefore, wouldn't it cause the same issues of "robustness"?<br /><br />I'm uncertain as to what you mean by "processing line." I'd appreciate whatever advice you can give.<br /><br />Thank you.Tonyahttps://www.blogger.com/profile/11132870025925083476noreply@blogger.comtag:blogger.com,1999:blog-367223172444482925.post-71680005678932291132010-09-10T00:03:27.572-07:002010-09-10T00:03:27.572-07:00Sorry but in your case, you're doing it wrong....Sorry but in your case, you're doing it wrong.<br /><br />By using foreach, no collection change is implied. Even if there is no exception, what should foreach do with an added item, or when the current item is removed? foreach means no change of collection.<br /><br />Since you want to process a real-time change of data, you need a more robust process, instead of using a collection or array for processing. Every time the state of data changes, the collection changes, and there's noway to indicate which one was processed, which not with a collection. You should use a queue or a processing line for that.<br /><br />Trying to use a collection for your case is a disaster waiting to happen. Sooner or later, you'll spend way more time to find out why some item as not correctly processed, at random time.Anonymousnoreply@blogger.com