IntelliJ Java IDE
The moose likes Performance and the fly likes How to compare two hashsets ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "How to compare two hashsets ?" Watch "How to compare two hashsets ?" New topic
Author

How to compare two hashsets ?

Vince Hon
Ranch Hand

Joined: Feb 11, 2003
Posts: 117
I have two HashSets,
e.g. hs_1, hs_2
I want to compare these 2 hashsets to produce a new one so that hs_1 will not contain elements of hs_2
Are there any efficient method to do this ?
Thanks


Vince Hon<br /> <br />SCJP 1.4 | SCWCD | SCBCD <br /><a href="http://vincehon.homeip.net:8000/VJW" target="_blank" rel="nofollow">http://vincehon.homeip.net:8000/VJW</a>
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The compact way:The efficient way:Alternatively, you can just let others worry about things by using the Jakarta Commons Collections:Hope this helps
- Peter
 
 
subject: How to compare two hashsets ?
 
Threads others viewed
Inserting several text files into individual hash sets
is LinkedHashSet ordered?
Dataset's any small examples?
String literal and String object comparison
Compare two HashSet
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com