it.unimi.dsi.fastutil.ints.IntComparator Java Examples
The following examples show how to use
it.unimi.dsi.fastutil.ints.IntComparator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntComparatorChain.java From tablesaw with Apache License 2.0 | 6 votes |
public int compare(int o1, int o2) throws UnsupportedOperationException { if (!this.isLocked) { this.checkChainIntegrity(); this.isLocked = true; } Iterator<IntComparator> comparators = this.comparatorChain.iterator(); for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) { IntComparator comparator = comparators.next(); int retval = comparator.compare(o1, o2); if (retval != 0) { if (this.orderingBits.get(comparatorIndex)) { if (retval > 0) { retval = -1; } else { retval = 1; } } return retval; } } return 0; }
Example #2
Source File: ArraysOverlapFunction.java From presto with Apache License 2.0 | 6 votes |
private static IntComparator intBlockCompare(Type type, Block block) { return new AbstractIntComparator() { @Override public int compare(int left, int right) { if (block.isNull(left) && block.isNull(right)) { return 0; } if (block.isNull(left)) { return 1; } if (block.isNull(right)) { return -1; } return type.compareTo(block, left, block, right); } }; }
Example #3
Source File: IntComparatorChain.java From tablesaw with Apache License 2.0 | 6 votes |
public int compare(int o1, int o2) throws UnsupportedOperationException { if (!this.isLocked) { this.checkChainIntegrity(); this.isLocked = true; } Iterator<IntComparator> comparators = this.comparatorChain.iterator(); for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) { IntComparator comparator = comparators.next(); int retval = comparator.compare(o1, o2); if (retval != 0) { if (this.orderingBits.get(comparatorIndex)) { if (retval > 0) { retval = -1; } else { retval = 1; } } return retval; } } return 0; }
Example #4
Source File: TableSlice.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns an array of integers representing the source table indexes in sorted order. */ private int[] sortOn(IntComparator rowComparator) { int[] newRows; if (hasSelection()) { newRows = this.selection.toArray(); } else { newRows = IntStream.range(0, table.rowCount()).toArray(); } IntArrays.parallelQuickSort(newRows, rowComparator); return newRows; }
Example #5
Source File: IntComparatorChain.java From tablesaw with Apache License 2.0 | 5 votes |
private IntComparatorChain(IntComparator comparator, boolean reverse) { this.orderingBits = null; this.isLocked = false; this.comparatorChain = new ArrayList<>(1); this.comparatorChain.add(comparator); this.orderingBits = new BitSet(1); if (reverse) { this.orderingBits.set(0); } }
Example #6
Source File: TableSlice.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns an array of integers representing the source table indexes in sorted order. */ private int[] sortOn(IntComparator rowComparator) { int[] newRows; if (hasSelection()) { newRows = this.selection.toArray(); } else { newRows = IntStream.range(0, table.rowCount()).toArray(); } IntArrays.parallelQuickSort(newRows, rowComparator); return newRows; }
Example #7
Source File: TableSlice.java From tablesaw with Apache License 2.0 | 5 votes |
/** * Sort this view in place without modifying or copying the underlying source table. Unlike {@link * Table#sortOn(Sort)} which returns a copy of the table, this method sorts the view in place. * * @param key to sort on. */ public void sortOn(Sort key) { Preconditions.checkArgument(!key.isEmpty()); if (key.size() == 1) { IntComparator comparator = SortUtils.getComparator(table, key); this.sortOrder = sortOn(comparator); } else { IntComparatorChain chain = SortUtils.getChain(table, key); this.sortOrder = sortOn(chain); } }
Example #8
Source File: SortUtils.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns a comparator chain for sorting according to the given key */ public static IntComparatorChain getChain(Table table, Sort key) { Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator(); Map.Entry<String, Sort.Order> sort = entries.next(); Column<?> column = table.column(sort.getKey()); IntComparator comparator = rowComparator(column, sort.getValue()); IntComparatorChain chain = new IntComparatorChain(comparator); while (entries.hasNext()) { sort = entries.next(); chain.addComparator(rowComparator(table.column(sort.getKey()), sort.getValue())); } return chain; }
Example #9
Source File: SortUtils.java From tablesaw with Apache License 2.0 | 5 votes |
/** * Returns a comparator that can be used to sort the records in this table according to the given * sort key */ public static IntComparator getComparator(Table table, Sort key) { Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator(); Map.Entry<String, Sort.Order> sort = entries.next(); Column<?> column = table.column(sort.getKey()); return SortUtils.rowComparator(column, sort.getValue()); }
Example #10
Source File: Table.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns a copy of this table sorted using the given comparator */ public Table sortOn(Comparator<Row> rowComparator) { Row row1 = new Row(this); Row row2 = new Row(this); return sortOn( (IntComparator) (k1, k2) -> { row1.at(k1); row2.at(k2); return rowComparator.compare(row1, row2); }); }
Example #11
Source File: Table.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns a copy of this table sorted using the given comparator */ private Table sortOn(IntComparator rowComparator) { Table newTable = emptyCopy(rowCount()); int[] newRows = rows(); IntArrays.parallelQuickSort(newRows, rowComparator); Rows.copyRowsToTable(newRows, this, newTable); return newTable; }
Example #12
Source File: Table.java From tablesaw with Apache License 2.0 | 5 votes |
/** * Returns a copy of this table sorted using the given sort key. * * @param key to sort on. * @return a sorted copy of this table. */ public Table sortOn(Sort key) { Preconditions.checkArgument(!key.isEmpty()); if (key.size() == 1) { IntComparator comparator = SortUtils.getComparator(this, key); return sortOn(comparator); } IntComparatorChain chain = SortUtils.getChain(this, key); return sortOn(chain); }
Example #13
Source File: Table.java From tablesaw with Apache License 2.0 | 5 votes |
/** * Returns a copy of this table sorted using the given sort key. * * @param key to sort on. * @return a sorted copy of this table. */ public Table sortOn(Sort key) { Preconditions.checkArgument(!key.isEmpty()); if (key.size() == 1) { IntComparator comparator = SortUtils.getComparator(this, key); return sortOn(comparator); } IntComparatorChain chain = SortUtils.getChain(this, key); return sortOn(chain); }
Example #14
Source File: TableSlice.java From tablesaw with Apache License 2.0 | 5 votes |
/** * Sort this view in place without modifying or copying the underlying source table. Unlike {@link * Table#sortOn(Sort)} which returns a copy of the table, this method sorts the view in place. * * @param key to sort on. */ public void sortOn(Sort key) { Preconditions.checkArgument(!key.isEmpty()); if (key.size() == 1) { IntComparator comparator = SortUtils.getComparator(table, key); this.sortOrder = sortOn(comparator); } else { IntComparatorChain chain = SortUtils.getChain(table, key); this.sortOrder = sortOn(chain); } }
Example #15
Source File: Table.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns a copy of this table sorted using the given comparator */ private Table sortOn(IntComparator rowComparator) { Table newTable = emptyCopy(rowCount()); int[] newRows = rows(); IntArrays.parallelQuickSort(newRows, rowComparator); Rows.copyRowsToTable(newRows, this, newTable); return newTable; }
Example #16
Source File: SortUtils.java From tablesaw with Apache License 2.0 | 5 votes |
/** * Returns a comparator that can be used to sort the records in this table according to the given * sort key */ public static IntComparator getComparator(Table table, Sort key) { Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator(); Map.Entry<String, Sort.Order> sort = entries.next(); Column<?> column = table.column(sort.getKey()); return SortUtils.rowComparator(column, sort.getValue()); }
Example #17
Source File: SortUtils.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns a comparator chain for sorting according to the given key */ public static IntComparatorChain getChain(Table table, Sort key) { Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator(); Map.Entry<String, Sort.Order> sort = entries.next(); Column<?> column = table.column(sort.getKey()); IntComparator comparator = rowComparator(column, sort.getValue()); IntComparatorChain chain = new IntComparatorChain(comparator); while (entries.hasNext()) { sort = entries.next(); chain.addComparator(rowComparator(table.column(sort.getKey()), sort.getValue())); } return chain; }
Example #18
Source File: IntComparatorChain.java From tablesaw with Apache License 2.0 | 5 votes |
private IntComparatorChain(IntComparator comparator, boolean reverse) { this.orderingBits = null; this.isLocked = false; this.comparatorChain = new ArrayList<>(1); this.comparatorChain.add(comparator); this.orderingBits = new BitSet(1); if (reverse) { this.orderingBits.set(0); } }
Example #19
Source File: Table.java From tablesaw with Apache License 2.0 | 5 votes |
/** Returns a copy of this table sorted using the given comparator */ public Table sortOn(Comparator<Row> rowComparator) { Row row1 = new Row(this); Row row2 = new Row(this); return sortOn( (IntComparator) (k1, k2) -> { row1.at(k1); row2.at(k2); return rowComparator.compare(row1, row2); }); }
Example #20
Source File: Interval.java From database with GNU General Public License v2.0 | 4 votes |
public IntComparator comparator() { return null; }
Example #21
Source File: ReversingIntComparator.java From tablesaw with Apache License 2.0 | 4 votes |
private ReversingIntComparator(IntComparator intComparator) { this.intComparator = intComparator; }
Example #22
Source File: ReversingIntComparator.java From tablesaw with Apache License 2.0 | 4 votes |
public static IntComparator reverse(IntComparator intComparator) { return new ReversingIntComparator(intComparator); }
Example #23
Source File: DateTimeColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return comparator; }
Example #24
Source File: StringColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return rowComparator; }
Example #25
Source File: BooleanColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return comparator; }
Example #26
Source File: TextColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return rowComparator; }
Example #27
Source File: TimeColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return comparator; }
Example #28
Source File: DateColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return comparator; }
Example #29
Source File: NumberColumn.java From tablesaw with Apache License 2.0 | 4 votes |
/** * Compares the given ints, which refer to the indexes of the doubles in this column, according to * the values of the doubles themselves */ @Override public IntComparator rowComparator() { return comparator; }
Example #30
Source File: InstantColumn.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public IntComparator rowComparator() { return comparator; }