private static int[] toFieldPosMap(int[] selectedFields) { int[] fieldIdxs = Arrays.copyOf(selectedFields, selectedFields.length); Arrays.sort(fieldIdxs); int[] fieldPosMap = new int[selectedFields.length]; for (int i = 0; i < selectedFields.length; i++) { int pos = Arrays.binarySearch(fieldIdxs, selectedFields[i]); fieldPosMap[pos] = i; } return fieldPosMap; }
/** * Returns a copy of {@code multiset} as an {@link ImmutableMultiset} whose iteration order is * highest count first, with ties broken by the iteration order of the original multiset. * * @since 11.0 */ @Beta public static <E> ImmutableMultiset<E> copyHighestCountFirst(Multiset<E> multiset) { Entry<E>[] entries = (Entry<E>[]) multiset.entrySet().toArray(new Entry[0]); Arrays.sort(entries, DecreasingCount.INSTANCE); return ImmutableMultiset.copyFromEntries(Arrays.asList(entries)); }
private static String[] listAll(Path dir, Set<String> skipNames) throws IOException { List<String> entries = new ArrayList<>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path path : stream) { String name = path.getFileName().toString(); if (skipNames == null || skipNames.contains(name) == false) { entries.add(name); } } } String[] array = entries.toArray(new String[entries.size()]); // Directory.listAll javadocs state that we sort the results here, so we don't let filesystem // specifics leak out of this abstraction: Arrays.sort(array); return array; }
/** * @param cues A list of the cues in this subtitle. */ public WebvttSubtitle(List<WebvttCue> cues) { this.cues = cues; numCues = cues.size(); cueTimesUs = new long[2 * numCues]; for (int cueIndex = 0; cueIndex < numCues; cueIndex++) { WebvttCue cue = cues.get(cueIndex); int arrayIndex = cueIndex * 2; cueTimesUs[arrayIndex] = cue.startTime; cueTimesUs[arrayIndex + 1] = cue.endTime; } sortedCueTimesUs = Arrays.copyOf(cueTimesUs, cueTimesUs.length); Arrays.sort(sortedCueTimesUs); }
public FSTFieldInfo[] getFieldArray() { if (infoArr == null) { List<FSTClazzInfo.FSTFieldInfo> fields = getFields(); final FSTFieldInfo[] fstFieldInfos = new FSTFieldInfo[fields.size()]; fields.toArray(fstFieldInfos); Arrays.sort(fstFieldInfos, defFieldComparator); infoArr = fstFieldInfos; } return infoArr; }
public List<IMetaMember> getMetaMembers() { List<IMetaMember> result = new ArrayList<>(); IMetaMember[] constructorsArray = classConstructors.toArray(new IMetaMember[classConstructors.size()]); Arrays.sort(constructorsArray); IMetaMember[] methodsArray = classMethods.toArray(new IMetaMember[classMethods.size()]); Arrays.sort(methodsArray); result.addAll(Arrays.asList(constructorsArray)); result.addAll(Arrays.asList(methodsArray)); return result; }
} else { List<Cookie> cookiesList = InternalThreadLocalMap.get().arrayList(); cookiesList.add(firstCookie); while (cookiesIt.hasNext()) { cookiesList.add(cookiesIt.next()); Cookie[] cookiesSorted = cookiesList.toArray(new Cookie[0]); Arrays.sort(cookiesSorted, COOKIE_COMPARATOR); for (Cookie c : cookiesSorted) { encode(buf, c);
ts.add(tableBaseName + "1"); ts.add(tableBaseName + "2"); Table tbl1 = createTestTable(dbName, ts.get(0)); hm.createTable(tbl1); Table tbl2 = createTestTable(dbName, ts.get(1)); hm.createTable(tbl2); Table table1 = hm.getTable(dbName, ts.get(0)); assertNotNull(table1); assertEquals(ts.get(0), table1.getTableName()); assertTrue(fs.exists(path2)); Path trash2 = mergePaths(trashDir, path2); System.out.println("trashDir2 is " + trash2); pathglob = trash2.suffix("*"); before = fs.globStatus(pathglob); assertFalse(fs.exists(path2)); after = fs.globStatus(pathglob); Arrays.sort(before); Arrays.sort(after); assertEquals("trash dir before and after DROP TABLE PURGE are different", before.length, after.length); System.err.println(StringUtils.stringifyException(e)); System.err.println("testDropTableTrash() failed"); throw e;
Constructor<?>[] ctors = type.getConstructors(); Arrays.sort(ctors, (c1, c2) -> { int c1pl = c1.getParameterCount(); int c2pl = c2.getParameterCount(); List<TypeDescriptor> paramDescriptors = new ArrayList<>(paramTypes.length); for (int i = 0; i < paramTypes.length; i++) { paramDescriptors.add(new TypeDescriptor(new MethodParameter(ctor, i))); if (ctor.isVarArgs() && argumentTypes.size() >= paramTypes.length - 1) { else if (paramTypes.length == argumentTypes.size()) {
@Override public ResultSet getTableTypes() throws SQLException { String[] types = tableTypeClauses.keySet().toArray(new String[0]); Arrays.sort(types); Field[] f = new Field[1]; List<byte[][]> v = new ArrayList<byte[][]>(); f[0] = new Field("TABLE_TYPE", Oid.VARCHAR); for (String type : types) { byte[][] tuple = new byte[1][]; tuple[0] = connection.encodeString(type); v.add(tuple); } return ((BaseStatement) createMetaDataStatement()).createDriverResultSet(f, v); }
public void registerOnGroupValueUpdateListener( IReceiverGroup.OnGroupValueUpdateListener onGroupValueUpdateListener){ if(mOnGroupValueUpdateListeners.contains(onGroupValueUpdateListener)) return; mOnGroupValueUpdateListeners.add(onGroupValueUpdateListener); //sort it for Arrays.binarySearch(); String[] keyArrays = onGroupValueUpdateListener.filterKeys(); Arrays.sort(keyArrays); mListenerKeys.put(onGroupValueUpdateListener, keyArrays); //when listener add, if user observe keys in current KeySet, call back it. checkCurrentKeySet(onGroupValueUpdateListener); }
private void sampleThresholds(int yi){ _ti[yi] = (_newThresholds[yi].length >> 2); try{ Arrays.sort(_newThresholds[yi]);} catch(Throwable t){ System.out.println("got AIOOB during sort?! ary = " + Arrays.toString(_newThresholds[yi])); return; } // sort throws AIOOB sometimes! for (int i = 0; i < _newThresholds.length; i += 4) _newThresholds[yi][i >> 2] = _newThresholds[yi][i]; } @Override public void processRow(long gid, final double [] nums, final int ncats, final int [] cats, double [] responses /* time...*/){
static void assertFileContents(final int runNumber) throws IOException { final Path path = Paths.get(FOLDER + "/audit.tmp"); final List<String> lines = Files.readAllLines(path, Charset.defaultCharset()); int i = 1; final int size = lines.size(); for (final String string : lines) { if (string.startsWith(",,")) { final Path folder = Paths.get(FOLDER); final File[] files = folder.toFile().listFiles(); Arrays.sort(files); System.out.println("Run " + runNumber + ": " + Arrays.toString(files)); Assert.fail( String.format("Run %,d, line %,d of %,d: \"%s\" in %s", runNumber, i++, size, string, lines)); } } }
public static void main(String[] args) throws IOException { IsoFile isofile = new IsoFile("C:\\content\\bbb-small\\output_320x180-mjpeg.mp4"); ESDescriptorBox esDescriptorBox = Path.getPath(isofile, "/moov[0]/trak[0]/mdia[0]/minf[0]/stbl[0]/stsd[0]/mp4v[0]/esds[0]"); byte[] d = new byte[esDescriptorBox.getData().rewind().remaining()]; esDescriptorBox.getData().get(d); System.err.println(Hex.encodeHex(d)); Movie mRef = MovieCreator.build("C:\\content\\bbb-small\\output_320x180_150.mp4"); Track refTrack = mRef.getTracks().get(0); File baseDir = new File("C:\\content\\bbb-small"); File[] iFrameJpegs = baseDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jpg"); } }); Arrays.sort(iFrameJpegs); Movie mRes = new Movie(); mRes.addTrack(new OneJpegPerIframe("iframes", iFrameJpegs, refTrack)); new DefaultMp4Builder().build(mRes).writeContainer(new FileOutputStream("output-mjpeg.mp4").getChannel()); } }
out.print(indentString(indent)); if (appendToHeader != null && !appendToHeader.isEmpty()) { out.println(xpl_note.displayName() + appendToHeader); } else { out.println(xpl_note.displayName()); if (outputOperators != null) { ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put(OUTPUT_OPERATORS, Arrays.toString(outputOperators.toArray())); Arrays.sort(methods, new MethodComparator()); out.print(" "); out.println(val);
System.out.println("lower bounds = " + Arrays.toString(_lbs)); if(_srcDinfo._normMul != null) { for (int i = numoff; i < _srcDinfo.fullN(); ++i) { System.out.println("lbs = " + Arrays.toString(_lbs)); if((v = beta_constraints.vec("upper_bounds")) != null) { _ubs = map == null ? Utils.asDoubles(v) : mapVec(Utils.asDoubles(v), makeAry(names.length, Double.POSITIVE_INFINITY), map); System.out.println("upper bounds = " + Arrays.toString(_ubs)); throw new IllegalArgumentException("Missing vector of penalties (rho) in beta_constraints file."); String [] cols = new String[]{"names","rho","beta_given","lower_bounds","upper_bounds"}; Arrays.sort(cols); for(String str:beta_constraints.names()) if(Arrays.binarySearch(cols,str) < 0) Log.warn("unknown column in beta_constraints file: '" + str + "'");