@Override public void sortAscending() { Arrays.parallelSort(data.elements()); }
@Override public void sortAscending() { Arrays.parallelSort(data.elements()); }
@Override public void sortAscending() { int[] sorted = data.toIntArray(); Arrays.parallelSort(sorted); this.data = new IntArrayList(sorted); }
/** {@inheritDoc} */ @Override public Vector sort() { if (isArrayBased()) Arrays.parallelSort(sto.data()); else throw new UnsupportedOperationException(); return this; }
public void init(KylinConfig config, String project) { this.project = project; this.config = config; if (name != null) name = name.toUpperCase(Locale.ROOT); if (getDatabase() != null) setDatabase(getDatabase().toUpperCase(Locale.ROOT)); if (columns != null) { Arrays.parallelSort(columns, new Comparator<ColumnDesc>() { @Override public int compare(ColumnDesc col1, ColumnDesc col2) { Integer id1 = Integer.parseInt(col1.getId()); Integer id2 = Integer.parseInt(col2.getId()); return id1.compareTo(id2); } }); for (ColumnDesc col : columns) { col.init(this); } } }
FullPageId[] objects = cpPagesList.toArray(new FullPageId[cpPagesList.size()]); Arrays.parallelSort(objects, new Comparator<FullPageId>() { @Override public int compare(FullPageId o1, FullPageId o2) { int cmp = Long.compare(o1.groupId(), o2.groupId());
@Test public void testRandom() { Random rand = new Random(); int n = 1000; double[] nums = new double[n]; for (int i = 0; i < n; i++) { nums[i] = rand.nextDouble() * 1000000; } Arrays.parallelSort(nums); buf.clear(); dds.serialize(nums, buf); buf.flip(); double[] r = dds.deserialize(buf); assertArrayEquals(nums, r); System.out.println("doubles size of " + (n * 8) + " bytes serialized to " + buf.limit() + " bytes"); }
@Test public void testRandom2() { Random rand = new Random(); int n = 1000; double[] nums = new double[n]; for (int i = 0; i < n; i++) { nums[i] = rand.nextInt(); } Arrays.parallelSort(nums); buf.clear(); dds.serialize(nums, buf); buf.flip(); double[] r = dds.deserialize(buf); assertArrayEquals(nums, r); System.out.println("doubles size of " + (n * 8) + " bytes serialized to " + buf.limit() + " bytes"); }
private void testSpanningAndGetParent(CuboidScheduler scheduler, CubeDesc cube, long[] cuboidIds, long[] expectChildren) { Set<Long> totalSpanning = Sets.newHashSet(); for (long cuboidId : cuboidIds) { List<Long> spannings = scheduler.getSpanningCuboid(cuboidId); totalSpanning.addAll(spannings); System.out.println("Spanning result for " + cuboidId + "(" + Long.toBinaryString(cuboidId) + "): " + toString(spannings)); for (long child : spannings) { assertTrue(scheduler.isValid(child)); } } long[] spanningsArray = Longs.toArray(totalSpanning); Arrays.parallelSort(spanningsArray); Arrays.parallelSort(expectChildren); assertArrayEquals(expectChildren, spanningsArray); }
Arrays.parallelSort(timeRanges);
public static void main(String[] args) { long[] arrayOfLong = new long[20000]; Arrays.parallelSetAll(arrayOfLong, index -> ThreadLocalRandom.current().nextInt(1000000)); Arrays.stream(arrayOfLong).limit(10).forEach( i -> System.out.print(i + " ")); System.out.println(); Arrays.parallelSort(arrayOfLong); Arrays.stream(arrayOfLong).limit(10).forEach( i -> System.out.print(i + " ")); System.out.println(); } }
@Override public <T> SelectionAndFocus move(Integer[] selected, ObservableList<T> items, int focused) { if (isSubselection(selected, items)) { MultipleSelectionAndFocus newSelection = new MultipleSelectionAndFocus(focused); Arrays.parallelSort(selected, Collections.reverseOrder(Integer::compare)); if (isNotLast(selected, items)) { Arrays.stream(selected).forEach(i -> { Collections.swap(items, i, i + 1); newSelection.moveDown(i); }); return newSelection; } } return SelectionAndFocus.NULL; } },
@Override public <T> SelectionAndFocus move(Integer[] selected, ObservableList<T> items, int focused) { if (isSubselection(selected, items)) { MultipleSelectionAndFocus newSelection = new MultipleSelectionAndFocus(focused); Arrays.parallelSort(selected); if (isNotFirst(selected)) { Arrays.stream(selected).forEach(i -> { Collections.swap(items, i, i - 1); newSelection.moveUp(i); }); return newSelection; } } return SelectionAndFocus.NULL; } },
@Override public final void sortAscending() { Arrays.parallelSort(data); }
public static void main(String[] args) { String[] strings = { "x", "a", "c", "b", "y" }; Arrays.parallelSort(strings); System.out.println(Arrays.toString(strings)); // [a, b, c, x, y] }
static Rule[] getOrderedRules(final Rule[] rules) { final Comparator<Rule> c = Comparator.comparing(Rule::getSize).reversed().thenComparing(Rule::getPattern); final Rule[] result = Arrays.copyOf(rules, rules.length); parallelSort(result, c); return result; }
@Benchmark public void parallelSort() { Arrays.parallelSort(la); } }
@Override public void sortDescending() { Primitive64Array.negate(data, 0, data.length, 1, data); Arrays.parallelSort(data); Primitive64Array.negate(data, 0, data.length, 1, data); }
@Override public void sortDescending() { Primitive32Array.negate(data, 0, data.length, 1, data); Arrays.parallelSort(data); Primitive32Array.negate(data, 0, data.length, 1, data); }
@Override public void sortDescending() { Primitive32Array.negate(data, 0, data.length, 1, data); Arrays.parallelSort(data); Primitive32Array.negate(data, 0, data.length, 1, data); }