List of usage examples for java.util Arrays sort
public static void sort(Object[] a)
From source file:com.linkedin.pinot.core.segment.creator.impl.fwd.MultiValueUnsortedForwardIndexCreator.java
@Override public void index(int docId, int[] dictionaryIndices) { final int[] entries = Arrays.copyOf(dictionaryIndices, dictionaryIndices.length); Arrays.sort(entries); mVWriter.setIntArray(docId, entries); }
From source file:com.yahoo.platform.yui.coverage.report.CoverageReport.java
/** * Generates FileReport objects for every file in the report. *///from ww w . ja v a 2 s .c om private void generateFileReports() throws JSONException { String[] filenames = getFilenames(); Arrays.sort(filenames); items = new FileReport[filenames.length]; for (int i = 0; i < filenames.length; i++) { items[i] = new FileReport(filenames[i], data.getJSONObject(filenames[i])); } }
From source file:techtonic.WellBoreListener.java
public WellBoreListener(int id, WitsmlWellbore wellbore, JPanel pan, JComboBox xAxis, JComboBox yAxis, JPanel traj, JPanel logsPanel) { this.id = id; this.wellbore = wellbore; this.seriesMagger = seriesMagger; this.xAxis = xAxis; this.yAxis = yAxis; this.trajectoryPanel = traj; this.logPanel = logsPanel; chartPanel = pan;//from ww w . j a v a 2 s . c o m talker++; Arrays.sort(wellborePlot); // System.out.print("talker created ==>>> "+talker); }
From source file:com.indeed.lsmtree.core.TestVolatileGeneration.java
public void testIterator() throws Exception { final File logPath = new File(tmpDir, "tmp.log"); VolatileGeneration<Integer, Long> volatileGeneration = new VolatileGeneration(logPath, new IntSerializer(), new LongSerializer(), new ComparableComparator()); int[] random = new int[1000000]; Random r = new Random(0); for (int i = 0; i < random.length; i++) { random[i] = r.nextInt();/*from www . j av a 2 s. c o m*/ } for (int element : random) { volatileGeneration.put(element, (long) element); } int[] sorted = new int[random.length]; System.arraycopy(random, 0, sorted, 0, random.length); Arrays.sort(sorted); verifyIterationOrder(volatileGeneration, sorted); volatileGeneration.close(); volatileGeneration = new VolatileGeneration<Integer, Long>(new File(tmpDir, "tmp2.log"), new IntSerializer(), new LongSerializer(), new ComparableComparator()); volatileGeneration.replayTransactionLog(logPath); verifyIterationOrder(volatileGeneration, sorted); }
From source file:bkampfbot.modes.Lottery.java
public void run() { Output.printClockLn("Lotterie", 1); if (random) { Random generator = new Random(); int n[] = { -1, -1, -1, -1, -1 }; for (int i = 0; i < 5; i++) { int now = generator.nextInt(49); while (n[0] == now || n[1] == now || n[2] == now || n[3] == now || n[4] == now) { now = generator.nextInt(49); }//from w ww. ja va 2 s. c om Lottery.numbers[i] = now + 1; n[i] = now; } } else { String out = ""; for (int n : numbers) { out += n + " "; } Output.printTabLn("Benutze: " + out, Output.INFO); } Arrays.sort(Lottery.numbers); Utils.visit("lotto/history"); try { String s = Utils.getString("lotto/schein"); int start = s.indexOf("/img/flash/ankreuzen.swf"); if (start == -1) throw new NotPossible(); start -= 80; s = s.substring(start); int lineFront = s.indexOf('{'); int lineEnd = s.indexOf('}', lineFront + 1); s = s.substring(lineFront, lineEnd + 1); // Output.noteln(s); /* * { quelle: "/img/flash/ankreuzen.swf", minpoints: "300", * currentpoints: "136", jackpot: "132908", numbers: "", ticketid: * "0", STAGE_WIDTH: "708", STAGE_HEIGHT: "569" } */ JSONObject lottery = new JSONObject(new JSONTokener(s)); int minPoints = Integer.parseInt(lottery.getString("minpoints")); int currentPoints = Integer.parseInt(lottery.getString("currentpoints")); if (minPoints > currentPoints) { throw new NotPossible("Nicht gengend Punkte"); } if (!lottery.getString("numbers").equals("")) { throw new NotPossible("Du hast schon Nummern angegeben."); } // Send numbers List<NameValuePair> nvps = new ArrayList<NameValuePair>(); String numbers = ""; for (int i = 0; i < 5; i++) { numbers += Lottery.numbers[i]; if (i != 4) numbers += ","; } nvps.add(new BasicNameValuePair("numbers", numbers)); // send post Utils.getString("lotto/schein", nvps); Output.printTabLn("Nummern angekreuzt: " + numbers, 1); } catch (Exception e) { Output.printTabLn(e.getMessage(), 1); } }
From source file:edu.umn.cs.spatialHadoop.indexing.ZCurvePartitioner.java
/** * Create a ZCurvePartitioner from a list of points * @param zValues//from w w w .ja va 2 s. co m * @param capacity */ protected void createFromZValues(final long[] zValues, int capacity) { Arrays.sort(zValues); int numSplits = (int) Math.ceil((double) zValues.length / capacity); this.zSplits = new long[numSplits]; long maxZ = computeZ(mbr, mbr.x2, mbr.y2); for (int i = 0; i < numSplits; i++) { int quantile = (int) ((long) (i + 1) * zValues.length / numSplits); this.zSplits[i] = quantile == zValues.length ? maxZ : zValues[quantile]; } }
From source file:com.gettingagile.tisugly.analyzer.ASMAnalyzer.java
private ASMAnalyzer() { URL[] urls = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs(); for (URL url : urls) { loadClassesFromClasspath(new File(url.getFile())); }/*from w ww . j av a 2 s . co m*/ globals = dependencyVisitor.getGlobals(); Set<String> classPackages = dependencyVisitor.getPackages(); packageNames = classPackages.toArray(new String[classPackages.size()]); Arrays.sort(packageNames); }
From source file:com.opengamma.strata.math.impl.statistics.descriptive.PercentileCalculatorTest.java
private void assertResult(final double[] x, final int percentile) { final double[] copy = Arrays.copyOf(x, N); Arrays.sort(copy); int count = 0; CALCULATOR.setPercentile(((double) percentile) / N); final double value = CALCULATOR.apply(x); while (copy[count++] < value) { //intended }/* www .j a va 2s .c o m*/ assertEquals(count - 1, percentile); }
From source file:net.phoenix.nlp.pos.chmm.recognitor.DateTimeRecognitor.java
public DateTimeRecognitor(CorpusRepository dictionary) throws IOException { super(dictionary); CharsetCorpus chars = dictionary.getCorpus(CharsetFileCorpus.class); this.numbers = chars.getChars("datetime.number"); Arrays.sort(this.numbers); this.qualifiers = chars.getChars("datetime.qualifier"); Arrays.sort(this.qualifiers); log.info("DateTimeRecognitor ready."); }
From source file:com.opengamma.analytics.financial.model.volatility.surface.SABRATMVolatilityCalibrationFunction.java
public SABRDataBundle calibrate(final OptionDefinition option, final SABRDataBundle data) { Validate.notNull(option, "option"); Validate.notNull(data, "data"); final double beta = data.getBeta(); final double t = option.getTimeToExpiry(data.getDate()); final double rho = data.getRho(); final double ksi = data.getVolOfVol(); final double sigmaATM = data.getVolatility(t, option.getStrike()); final double b = data.getCostOfCarry(); final double f = data.getSpot() * Math.exp(b * t); final double beta1 = 1 - beta; final double f1 = Math.pow(f, beta1); final double a0 = -sigmaATM * f1; final double a1 = 1 + (2 - 3 * rho * rho) * ksi * ksi * t / 24; final double a2 = rho * beta * ksi * t / 4 / f1; final double a3 = beta1 * beta1 * t / 24 / f1 / f1; Double[] roots;/*from w w w. ja v a 2 s . c o m*/ if (CompareUtils.closeEquals(a3, 0, 1e-16)) { roots = QUADRATIC_FINDER.getRoots(new RealPolynomialFunction1D(new double[] { a0, a1, a2 })); } else { roots = ROOT_FINDER.getRoots(new RealPolynomialFunction1D(new double[] { a0, a1, a2, a3 })); } Arrays.sort(roots); if (roots[0] > 0) { return data.withAlpha(roots[0]); } for (final Double r : roots) { if (r > 0) { return data.withAlpha(r); } } throw new MathException("Could not find positive real root"); }