Here you can find the source of sortedPointersInto_usingStrictfp(final double d[])
public static strictfp int[] sortedPointersInto_usingStrictfp(final double d[])
//package com.java2s; //License from project: LGPL import java.util.Arrays; import java.util.Comparator; public class Main { /** strictfp needed to avoid violating Comparator. TODO This function, probably the strictfp part, is taking 3 times as much cpu time in physicsmata2.0.0 as the automata. *///from w w w . j a v a2 s. c o m public static strictfp int[] sortedPointersInto_usingStrictfp(final double d[]) { Integer Ints[] = new Integer[d.length]; for (int i = 0; i < d.length; i++) Ints[i] = i; Comparator<Integer> compare = new Comparator<Integer>() { public strictfp int compare(Integer x, Integer y) { double xd = d[x], yd = d[y]; if (xd < yd) return -1; if (xd > yd) return 1; return 0; } }; while (true) { try { Arrays.sort(Ints, compare); break; } catch (Exception e) { System.out.println( "This is probably 'Comparison method violates its general contract' which strictfp avoids always singlethreaded but it appears some thread is using it, but which one could it be since its a local var? For now, since it happens only 1 20000 times its faster to just catch this and do it again those times. TODO find that thread and synchronize here and there! " + e.getMessage()); e.printStackTrace(System.out); } } int ints[] = new int[d.length]; for (int i = 0; i < d.length; i++) ints[i] = Ints[i]; return ints; } }