List of usage examples for java.util Arrays sort
public static void sort(Object[] a)
From source file:com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck.java
/** * Set the lines numbers to repeat in the header check. * @param list comma separated list of line numbers to repeat in header. *//*from w w w. ja va2 s. c o m*/ public void setMultiLines(int... list) { if (list.length == 0) { multiLines = EMPTY_INT_ARRAY; return; } multiLines = new int[list.length]; System.arraycopy(list, 0, multiLines, 0, list.length); Arrays.sort(multiLines); }
From source file:com.linkedin.pinot.perf.BenchmarkDictionaryCreation.java
@Setup public void setUp() throws IOException { FileUtils.forceMkdir(INDEX_DIR);//from w w w . ja va 2 s . c om for (int i = 0; i < CARDINALITY; i++) { _sortedInts[i] = i; _sortedLongs[i] = i; _sortedFloats[i] = i; _sortedDoubles[i] = i; _sortedStrings[i] = String.valueOf(i); } Arrays.sort(_sortedStrings); }
From source file:edu.cmu.tetrad.search.EstimateRank.java
public double[] CanCor(int[] iA, int[] iB, double[][] cov) { this.iA = iA; this.iB = iB; this.cov = cov; RealMatrix covA = new BlockRealMatrix(cov).getSubMatrix(iA, iA); RealMatrix covB = new BlockRealMatrix(cov).getSubMatrix(iB, iB); RealMatrix covAB = new BlockRealMatrix(cov).getSubMatrix(iA, iB); RealMatrix covBA = new BlockRealMatrix(cov).getSubMatrix(iB, iA); RealMatrix S = getInverse(covA).multiply(covAB).multiply(getInverse(covB)).multiply(covBA); double[] rtCors = new EigenDecomposition(S).getRealEigenvalues(); Arrays.sort(rtCors); double[] Cors = new double[rtCors.length]; for (int i = rtCors.length; i > 0; i--) { Cors[rtCors.length - i] = Math.pow(rtCors[i - 1], .5); }/*from w ww . j a v a 2s .c o m*/ return Cors; }
From source file:org.apache.taverna.activities.wsdl.xmlsplitter.XMLSplitterConfigurationBeanBuilder.java
public static JsonNode buildBeanForInput(Element element) throws JDOMException, IOException { ObjectNode bean = JSON_NODE_FACTORY.objectNode(); ArrayNode inputDefinitions = bean.arrayNode(); bean.put("inputPorts", inputDefinitions); ArrayNode outputDefinitions = bean.arrayNode(); bean.put("outputPorts", outputDefinitions); TypeDescriptor descriptor = XMLSplitterSerialisationHelper.extensionXMLToTypeDescriptor(element); ObjectNode outBean = outputDefinitions.addObject(); outBean.put("name", "output"); outBean.put("mimeType", "'text/xml'"); outBean.put("depth", 0); outBean.put("granularDepth", 0); if (descriptor instanceof ComplexTypeDescriptor) { List<TypeDescriptor> elements = ((ComplexTypeDescriptor) descriptor).getElements(); String[] names = new String[elements.size()]; Class<?>[] types = new Class<?>[elements.size()]; TypeDescriptor.retrieveSignature(elements, names, types); for (int i = 0; i < names.length; i++) { ObjectNode portBean = inputDefinitions.addObject(); portBean.put("name", names[i]); portBean.put("mimeType", TypeDescriptor.translateJavaType(types[i])); portBean.put("depth", depthForDescriptor(elements.get(i))); }//w w w . jav a 2 s. c o m List<TypeDescriptor> attributes = ((ComplexTypeDescriptor) descriptor).getAttributes(); String[] elementNames = Arrays.copyOf(names, names.length); Arrays.sort(elementNames); String[] attributeNames = new String[attributes.size()]; Class<?>[] attributeTypes = new Class<?>[attributes.size()]; TypeDescriptor.retrieveSignature(attributes, attributeNames, attributeTypes); for (int i = 0; i < attributeNames.length; i++) { ObjectNode portBean = inputDefinitions.addObject(); if (Arrays.binarySearch(elementNames, attributeNames[i]) < 0) { portBean.put("name", attributeNames[i]); } else { portBean.put("name", "1" + attributeNames[i]); } portBean.put("mimeType", TypeDescriptor.translateJavaType(attributeTypes[i])); portBean.put("depth", depthForDescriptor(attributes.get(i))); } } else if (descriptor instanceof ArrayTypeDescriptor) { ObjectNode portBean = inputDefinitions.addObject(); portBean.put("name", descriptor.getName()); if (((ArrayTypeDescriptor) descriptor).getElementType() instanceof BaseTypeDescriptor) { portBean.put("mimeType", "l('text/plain')"); } else { portBean.put("mimeType", "l('text/xml')"); } portBean.put("depth", 1); } String wrappedType = new XMLOutputter().outputString(element); bean.put("wrappedType", wrappedType); return bean; }
From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Sort.java
/** * Sorts values statelessly in order given by enumeration * @param v1 the values to sort (a native backed array) * @param d the direction in which the sorted array should be returned (based on {@link direction}) * @return tmp the sorted values/* www. j av a 2s.c o m*/ */ public static float[] stateless(float[] v1, direction d) { Validate.notNull(v1); float[] tmp = Arrays.copyOf(v1, v1.length); Arrays.sort(tmp); switch (d) { case ascend: break; case descend: Reverse.inPlace(tmp); } return tmp; }
From source file:ca.nines.ise.util.CodePointTable.java
public String[] getCodePoints() { String names[] = table.keySet().toArray(new String[table.size()]); Arrays.sort(names); return names; }
From source file:de.uni.bremen.monty.moco.util.MontyFile.java
@Override public MontyResource[] listSubModules() { MontyResource[] montyResources = convertAllFiles( listFiles((FilenameFilter) new SuffixFileFilter(".monty"))); Arrays.sort(montyResources); return montyResources; }
From source file:fr.ericlab.util.Util.java
static public double getMedian(double array[]) { Arrays.sort(array); return array[array.length / 2]; }
From source file:com.yahoo.platform.yuitest.coverage.results.SummaryCoverageReport.java
/** * Generates FileCoverageReport objects for every file in the report. *///from w ww .ja va2 s. co m private void generateFileReports() throws JSONException { String[] filenames = getFilenames(); Arrays.sort(filenames); files = new FileCoverageReport[filenames.length]; directories.clear(); for (int i = 0; i < filenames.length; i++) { files[i] = new FileCoverageReport(filenames[i], data.getJSONObject(filenames[i])); if (!directories.containsKey(files[i].getFileParent())) { directories.put(files[i].getFileParent(), new DirectoryCoverageReport(files[i].getFileParent())); } directories.get(files[i].getFileParent()).addFileReport(files[i]); } }
From source file:ArrayHunt.java
/** Play one game. */ public boolean play() { int i;/*from ww w.j av a 2 s. c o m*/ // Fill the array with random data (hay?) for (i = 0; i < MAX; i++) { haystack[i] = (int) (r.nextFloat() * MAX); } // Precondition for binary search is that data be sorted! Arrays.sort(haystack); // Look for needle in haystack i = Arrays.binarySearch(haystack, NEEDLE); if (i >= 0) { // Found it, we win. System.out.println("Value " + NEEDLE + " occurs at haystack[" + i + "]"); return true; } else { // Not found, we lose. System.out.println("Value " + NEEDLE + " does not occur in haystack; nearest value is " + haystack[-(i + 2)] + " (found at " + -(i + 2) + ")"); return false; } }