publicclassArrays { /** * The minimum array length below which a parallel sorting * algorithm will not further partition the sorting task. Using * smaller sizes typically results in memory contention across * tasks that makes parallel speedups unlikely. */privatestaticfinalint MIN_ARRAY_SORT_GRAN =1<<13;// Suppresses default constructor, ensuring non-instantiability.privateArrays() {} /** * A comparator that implements the natural ordering of a group of * mutually comparable elements. May be used when a supplied * comparator is null. To simplify code-sharing within underlying * implementations, the compare method only declares type Object * for its second argument. * * Arrays class implementor's note: It is an empirical matter * whether ComparableTimSort offers any performance benefit over * TimSort used with this comparator. If not, you are better off * deleting or bypassing ComparableTimSort. There is currently no * empirical case for separating them for parallel sorting, so all * public Object parallelSort methods use the same comparator * based implementation. */staticfinalclassNaturalOrderimplementsComparator<Object> { @SuppressWarnings("unchecked")publicintcompare(Object first,Object second) {return ((Comparable<Object>)first).compareTo(second); }staticfinalNaturalOrder INSTANCE =newNaturalOrder(); }...
publicfinalclassMath { /** * Don't let anyone instantiate this class. */privateMath() {} /** * The {@code double} value that is closer than any other to * <i>e</i>, the base of the natural logarithms. */publicstaticfinaldouble E =2.7182818284590452354; /** * The {@code double} value that is closer than any other to * <i>pi</i>, the ratio of the circumference of a circle to its * diameter. */publicstaticfinaldouble PI =3.14159265358979323846; /** * Returns the trigonometric sine of an angle. Special cases: * <ul><li>If the argument is NaN or an infinity, then the * result is NaN. * <li>If the argument is zero, then the result is a zero with the * same sign as the argument.</ul> * * <p>The computed result must be within 1 ulp of the exact result. * Results must be semi-monotonic. * * @param a an angle, in radians. * @return the sine of the argument. */publicstaticdoublesin(double a) {returnStrictMath.sin(a); // default impl. delegates to StrictMath }