Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Did the sort do anything? Date: Mon, 16 May 2011 03:44:34 -0400 Organization: albasani.net Lines: 33 Message-ID: References: <9303hcFq0nU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net ZRruA/1FbvNNqHcN6ETcOSM0uxPpJ15ankDkjQBlZvi4kx5iifArpqnNmjJityJIjbGfn1aYveYdtsvXbUDlBKYvQjRTv9NAsYPDKMR9jxn53l5upN+j0g08E3ZjZbm1 NNTP-Posting-Date: Mon, 16 May 2011 07:44:31 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="wBZ50C2ZaDtjmO0L7rfbtkQ26H7cvikzjQZoF7GzL6qVaPpZr+udqwW2dQcrPjpvspSBJPUAntxJcxg67KaFWHhsVbOA/EbRYAMRwFKK06u1zn91e4UWyfcD7tBgGtgR"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:sBFc9j7du34KLpln6PZ8UwtDXmE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4151 Lawrence D'Oliveiro wrote: > Patricia Shanahan wrote: >> Lawrence D'Oliveiro wrote: >>> If, on the other hand, you were sorting immutable objects of a Java >>> “reference” type where the key was the entire object state, then >>> stability would indeed be irrelevant, notwithstanding such types are not >>> considered “primitive”. >> Do you consider the result of System.identityHashCode(x) to be part of >> the state of the object referenced by x? > It is computed from the state, is it not? No. It most certainly is not. The identity hash code is computed once for each object irrespective of and independently of anything else you might consider the object's state. As a cursory reading of the Javadocs makes clear: Even without the rather intelligent step of checking the documentation, you can reason out that the answer must be no. Either the identity hash code is part of the state, in which case it is not computed from the state but *is* part of the state, or it is not, in which case it is not computed from the state. Which it is depends on your definition of "the state", i.e., whether you include the identity hash code as part of the state. Yes, it's tautological, but that's the result of the way you framed the question. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg