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 10:02:05 -0400 Organization: albasani.net Lines: 37 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 rbm8u9mxeHcvw5MoIed+RdRgUlo5NAbzQ+YbVZbNatTg7OpnDdFtW3QO4TaE45+HdOTV55yy1JSMLgl33lQvg8Kj1stcgo96w+VxxU3VqUVzx3YrMH+b6EoBXqP3aBw9 NNTP-Posting-Date: Mon, 16 May 2011 14:01:59 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="8HSZVDXW/VP90wpyqnW/sIimwprbNS7vzQBodbTVDSypLGJTPsPbhLi0bFKEt5ONwOO6HKuqusg8JjIE1V0ScI0xaCBNDuzKp+GncigDIDk2RHNvrnv0mDoZgJrjUzu1"; 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:GGrWMOHfvYR1gih6VrvoLh+Czus= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4160 On 05/16/2011 08:02 AM, Lawrence D'Oliveiro wrote: > In message, Patricia > Shanahan wrote: > >> Distinct objects probably have different identity hash codes regardless of >> whether their fields all have the same values. > > “By contract, any two objects for which equals(Object) returns true must > return the same hash code value.” > > That's the wrong reference, as that is not the method under discussion. The discussion is about a different method in a different class: > “Distinct” would presumably mean “not equal”. except for the little matter of that documentation being not relevant. >> Its existence ensures that program behavior can be affected by object >> sort stability or instability, even if the sort key includes all fields. >> The sort key would have to also include the identity hash code to make >> stability irrelevant. > > The sort key would have to be consistent with the definition of “equality”, > would it not? Not in the case of identity hash code, no. I gave the correct API reference upthread. Note that there is no requirement or hint for consistency with 'equals()'. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg