Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Gene Wirchenko Newsgroups: comp.lang.java.programmer Subject: Re: StringBuilder Difficulties Date: Tue, 05 Jul 2011 17:29:27 -0700 Organization: A noiseless patient Spider Lines: 60 Message-ID: References: <97h616FhaeU3@mid.individual.net> <97hd9sFa1jU2@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="7Qrvczazr82YckO5XW8Vtw"; logging-data="26676"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+tBgP3365U1LAIptTcGwrcSIbidXF0K8=" X-Newsreader: Forte Agent 4.2/32.1118 Cancel-Lock: sha1:vwH7aHsau7QJs3lGphWQSr8YHYg= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5878 On 5 Jul 2011 21:16:44 GMT, blmblm@myrealbox.com wrote: >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. I set the string value that way so that the binary search would work. >> 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? I would need to know what the behaviour is supposed to be. I have something that works for now. Optimisation comes after getting it working. >> 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 .... 1) Just in case there was a BIG difference. 2) To learn more about Java. At some point though, I have to do something useful with it. My preprocessor is shaping up nicely. I have to write the symbol define command code, handle the include command, and handle output to a file. That is about it. Which means that there are probably only about three other things that I will come up. Sincerely, Gene Wirchenko