Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: blmblm@myrealbox.com Newsgroups: comp.lang.java.programmer Subject: Re: StringBuilder Difficulties Date: 5 Jul 2011 21:16:44 GMT Organization: None Lines: 46 Message-ID: <97hd9sFa1jU2@mid.individual.net> References: <97h616FhaeU3@mid.individual.net> X-Trace: individual.net F+hynIUAf3MJZWCAfcYIQg5dvrJLMLpSjdVi75BLNpxaa61Om0 X-Orig-Path: not-for-mail Cancel-Lock: sha1:R+uHpK+NPqk1YQdfAvHoI6gQvrM= X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5874 In article , Gene Wirchenko wrote: > On 5 Jul 2011 19:12:39 GMT, blmblm@myrealbox.com > wrote: > > [snip] > > >What I found is that HashSet was noticeably faster on all the > >systems where I ran the benchmarks. Unless you need for the set > >to be sorted (and it's not apparent from your code that you do), > >why not .... ? (I'm curious too about why you chose TreeSet in > >the first place. ? ) > > 1) I can output the set in order without having to do anything else. > My real program has a lot of debugging info dumping. (Read as "checks > that I have not done something wrong".) Ah. Well, yes, then you probably do need a SortedSet, though considering that you initially build the set from a string that's in order, maybe you could use that (the string) instead. Just sayin', maybe. > 2) When I read "hash", I think "collision", and I get nervous. > Nothing I read reassured me that that could not happen. Why would that make you nervous? If you're worried about correctness, um, as far as I know hash tables are supposed to deal with collisions in some way that preserves the overall "map" semantics. Performance may suffer if there are a lot of collisions, but -- benchmark on the system(s) of interest and check? > 3) I had to pick something. If it works, I can change it later. If > it does not, I have not solved my problem yet. The former is safer. Sure. Then again, if you were only concerned about getting something that works, why try various alternatives .... -- B. L. Massingill ObDisclaimer: I don't speak for my employers; they return the favor.