954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

LinkedHashSet Itearator problem

hi forum,
i hv used an iterator to parse over the contents of a LinkedHashSet collection.while iterating i hv to add new contents(URL links) to the collection.but adding of new content after the creation of an iterator throws an exception.I must use this particular collection for my program.i m in a real bother over this.can anyone help?thanks.

p.s.this is related with my previous posts over implementation of a web crawler.

Dark Master
Newbie Poster
8 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

That's correct. When you add something to it any Iterators you have on it are invalidated.
Either defer the inserts until after you are done iterating (maybe add the stuff temporarilly to another Collection and later use addAll on the LinkedHashSet to add the content of that Collection or loop through the LinkedHashSet in some other way.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You