All pastes #784461 Raw Edit

What a Fuck

public java v1 · immutable
·published 2007-11-19 18:32 UTC
rendered paste body
protected int partition( int[] A, int left, int right ) 	{		                int p = getPivotIndex(A, left, right);                swap(A, p, right);		int x = A[right];                		int i = left -1 ;				for (int j = left; j< right; j++)		{			comparisons ++;			if (A[j]<=x){				comparisons++;				i++;				swap(A,i,j);			}		}		swap(A,i+1,right);		return i+1;	}	/**	 * 	 * This method computes the index of the pivot element depending on the	 * variable pivotType.	 * 	 * @param left Left border index.	 * @param right Right border index.	 * @return The index of the pivot element	 * @author Daniel Lang 22834 Aufgabe 4a)	 */	private int getPivotIndex( int[] A, int left, int right ) 	{		switch (pivotType){					case MIDPOINT:				//System.out.println("Auswahl des Pivotelement ueber Mittelpunkt des Array's ");				return A.length/2;											case RANDOMLY:					//System.out.println("Auswahl des Pivotelement ueber Random ");				return getRandom(left, right);											case MEDIAN_OF_3:				//System.out.println("Auswahl des Pivotelement ueber MEDIAN_OF_3 ");				int mid = (left + right)/2;				if (A[left] <= A[mid] && A[mid] <= A[right] || A[right] <= A[mid] && A[mid] <= A[left])								                                        return mid;								if (A[mid] <= A[left] && A[left] <= A[right] || A[right] <= A[left] && A[left] <= A[mid])								                                        return left;								if (A[left] <= A[right] && A[right] <= A[mid] || A[mid] <= A[right] && A[right] <= A[left])								                                        return right;							case LEFTBORDER:				//System.out.println("Auswahl des Pivotelement ueber Leftboarder ");				return left;										case RIGHTBORDER:				//System.out.println("Auswahl des Pivotelement ueber Rightboarder ");								return  right;							default:				//System.out.println("Keine Methode ausgewählt:");				return 0;							}	}