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

problems with HashSet

hi forum,
yesterday i posted a question regarding removing duplicate objects in arraylist and looking at the replies it seemed to me that hashset will be a better option than arraylist.problem is that i want the contents to be itearated strictly in order of their insertion, but the books say that hashset does not guarantee this.actually i m building a simple web crawler and i want this collection to hold the list of links extracted from a web page.naturally duplicate links should not be entered in the collection and so i posted the previous query regarding removing duplicates.plz help me with the choice of the collection. thanks.

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

Use a LinkedHashSet instead. It can be iterated over in insertion order, but is of course heavier as it needs to keep track of the insertion order (which it does by backing the Set with a List or array).

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