2604N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2604N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2604N/A * This code is free software; you can redistribute it and/or modify it 2604N/A * under the terms of the GNU General Public License version 2 only, as 2604N/A * published by the Free Software Foundation. 2604N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2604N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2604N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2604N/A * version 2 for more details (a copy is included in the LICENSE file that 2604N/A * You should have received a copy of the GNU General Public License version 2604N/A * 2 along with this work; if not, write to the Free Software Foundation, 2604N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2604N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2604N/A // As pivot we use the median of the first, last and middle elements. 2604N/A // We swap in these three values at the right place in the array. This 2604N/A // means that this method not only returns the index of the pivot 2604N/A // element. It also alters the array so that: 2604N/A // array[first] <= array[middle] <= array[last] 2604N/A // A side effect of this is that arrays of length <= 3 are sorted. 2604N/A // Now the value in the middle of the array is the median 2604N/A // of the fist, last and middle values. Use this as pivot. 2604N/A // arrays up to length 3 will be sorted after finding the pivot 2604N/A // The idempotent parameter prevents the sort from 2604N/A // reordering a previous valid sort by not swapping 2604N/A // fields that compare as equal. This requires extra 2604N/A // calls to the comparator, so the performance 2604N/A // impact depends on the comparator. 2604N/A // Switch "idempotent" from function paramter to template parameter 2604N/A#
endif //SHARE_VM_UTILITIES_QUICKSORT_HPP