Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 20 May 2011 23:26:56 -0500 Date: Fri, 20 May 2011 21:26:44 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Did the sort do anything? References: <9303hcFq0nU1@mid.individual.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 34 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-mZgNonks1aH8tqIjniDUz/Yk3loo6e1jnuFHOfSGx+nbVFi06Oj2QtMI9jBxZzcIyAXG9+7jfHGMX7J!PO/LaM9PI4mB+zjk/t3C0PY8GbpV8tQa6J3Jo48By7Gy1Xg8tTUaMADTjAJZVdzPHqka1R5zHcj5!ngVhffspuLnNQh30AXI+0KppJBajdVzw4qL2UdLsQj0= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3181 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4379 On 5/20/2011 2:56 PM, Lawrence D'Oliveiro wrote: > In message, Patricia Shanahan wrote: > >> On 5/20/2011 5:00 AM, Patricia Shanahan wrote: ... >> To further refresh your memory, the question I raised was whether you >> consider System.identityHashCode(x) to be part of the "entire object >> state" of the object referenced by x. > > What is the significance of sorting on a hash function? Sorting affects the order of events. Suppose there are a lot of equal objects. At hash map size N, many of them fall in the same bucket. At a higher size, they gets spread over two or more buckets, reducing collisions. The stability, or instability, of a sort algorithm can change the order of appearance, affecting which keys are added before resizing. That is just one way in which changing the order in a list of equal objects may be visible. If that is too subtle for your taste, consider the following: for(Integer x : myArray){ System.out.println(x + " " + System.identityHashCode(x)); } Arrays.sort(myArray); for(Integer x : myArray){ System.out.println(x + " " + System.identityHashCode(x)); } If the sort is stable, Integer objects with the same value appear in the same order in the two printouts. If it is not stable, they may be reordered. Patricia