Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32320

Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA")

From leif.roar@dimnakorr.com
Subject Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA")
Newsgroups comp.lang.java.programmer
References (1 earlier) <mq70q5$20v$1@dont-email.me> <5b08503d-429d-429a-b1af-852563619faa@googlegroups.com> <mqa870$9gi$1@dont-email.me> <55cbea08$0$301$14726298@news.sunsite.dk> <mqi29d$n37$1@dont-email.me>
Message-ID <E62dnemEP6qGAlHInZ2dnUU78XOdnZ2d@giganews.com> (permalink)
Date 2015-08-13 08:43 -0500

Show all headers | View raw


Eric Sosman <esosman@comcast-dot-net.invalid> wrote:
> 
>     Possibly, but possibly not.  The hash computation inspects
> every character of the string,[*] and the "yes, they're equal"
> comparison inspects each character a second time.  Unless the
> strings share long identical prefixes and differ only in their
> suffixes, mismatches between unequal pairs will be detected after
> only a few characters are inspected -- or even without inspecting
> any characters at all, if the lengths differ.  That is, for strings
> "chosen at random" (whatever *that* may mean), detecting inequality
> a few times might well be cheaper than computing a hash.

Don't forget that a) in practice you tend to switch on quite short 
strings and b) with the hash-code technique you'll almost never 
do more than _one_ string comparison regardless of the number of
case statements while with an if cascade you'd often have to do
several. 

-- 
Leif Roar Moldskred

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") srcommunicationsvja@gmail.com - 2015-08-08 06:53 -0700
  Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-08-08 10:39 -0400
  Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Eternal Hope <laughingspam99@gmail.com> - 2015-08-09 08:53 +0100
    Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") e.d.programmer@gmail.com - 2015-08-10 05:36 -0700
      Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-08-10 09:17 -0400
        Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") e.d.programmer@gmail.com - 2015-08-10 07:56 -0700
          Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-08-10 11:50 -0400
        Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Arne Vajhøj <arne@vajhoej.dk> - 2015-08-12 20:51 -0400
          Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-08-13 08:25 -0400
            Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") leif.roar@dimnakorr.com - 2015-08-13 08:43 -0500
      Re: PLEASE SOLVE THIS ERROR (case 1:from=="VIJAYAWADA") Eternal Hope <laughingspam99@gmail.com> - 2015-08-10 15:39 +0100

csiph-web