List of usage examples for com.google.common.primitives Longs compare
public static int compare(long a, long b)
From source file:org.renyan.leveldb.impl.InternalKeyComparator.java
@Override public int compare(InternalKey left, InternalKey right) { int result = userComparator.compare(left.getUserKey(), right.getUserKey()); if (result != 0) { return result; }/*from w w w.ja v a2 s . c o m*/ return Longs.compare(right.getSequenceNumber(), left.getSequenceNumber()); // reverse sorted version numbers }
From source file:org.cinchapi.concourse.util.NaturalSorter.java
@Override public int compare(File f1, File f2) { String[] s1 = f1.getName().split("\\."); String[] s2 = f2.getName().split("\\."); int result;/*from w w w .ja v a 2s . co m*/ return (result = Longs.compare(Long.parseLong(s1[0]), Long.parseLong(s2[0]))) == 0 ? s1[1].compareTo(s2[1]) : result; }
From source file:rabbit.ui.internal.viewers.TreeViewerColumnValueSorter.java
@Override public int doCompare(Viewer v, TreePath parentPath, Object e1, Object e2) { if (parentPath == null) { parentPath = TreePath.EMPTY; }/*from w w w .ja va 2 s . c om*/ return Longs.compare(valueProvider.getValue(parentPath.createChildPath(e1)), valueProvider.getValue(parentPath.createChildPath(e2))); }
From source file:com.b2international.snowowl.snomed.reasoner.server.diff.concretedomain.ConcreteDomainChangeOrdering.java
@Override public int compare(final ConcreteDomainFragment left, final ConcreteDomainFragment right) { final int typeDelta = left.getType() - right.getType(); if (typeDelta != 0) return typeDelta; final int attributeLabelDelta = left.getLabel().compareTo(right.getLabel()); if (attributeLabelDelta != 0) return attributeLabelDelta; final int uomDelta = Longs.compare(left.getUomId(), right.getUomId()); if (uomDelta != 0) return uomDelta; return left.getValue().compareTo(right.getValue()); }
From source file:org.apache.mahout.graph.model.Vertex.java
/** Compares this instance to another according to the {@code id} attribute. */ @Override//w ww. ja v a2s. c o m public int compareTo(Vertex other) { return Longs.compare(id, other.id); }
From source file:org.gradle.cache.internal.btree.BlockPointer.java
public int compareTo(BlockPointer o) { return Longs.compare(pos, o.pos); }
From source file:com.hippo.leveldb.impl.InternalKeyComparator.java
@Override public int compare(InternalKey left, InternalKey right) { InternalKey lKey = left;//ww w . j a v a 2s . c o m InternalKey rKey = right; if (lKey.original() && !lKey.simplified()) { lKey = lKey.simplify(); } if (rKey.original() && !rKey.simplified()) { rKey = rKey.simplify(); } int result = userComparator.compare(lKey.getUserKey(), rKey.getUserKey()); if (result != 0) { return result; } if (lKey.original() && rKey.original()) { result = Longs.compare(right.version(), left.version());// reverse if (result != 0) { return result; } } return Longs.compare(right.getSequenceNumber(), left.getSequenceNumber()); // reverse sorted version numbers }
From source file:com.facebook.stats.topk.ArrayBasedIntegerTopK.java
@Override public List<Integer> getTopK() { Comparator<Integer> comparator = new Comparator<Integer>() { public int compare(Integer i, Integer j) { return Longs.compare(counts[i], counts[j]); }// ww w . j a v a2 s . com }; PriorityQueue<Integer> topK = new PriorityQueue<Integer>(k, comparator); for (int key = 0; key < counts.length; ++key) { if (topK.size() < k) { if (counts[key] > 0) { topK.offer(key); } } else if (counts[key] > counts[topK.peek()]) { topK.poll(); topK.offer(key); } } LinkedList<Integer> sortedTopK = new LinkedList<Integer>(); while (!topK.isEmpty()) { sortedTopK.addFirst(topK.poll()); } return sortedTopK; }
From source file:eugene.market.esma.impl.execution.Execution.java
/** * Creates a {@link Execution} with this <code>execID</code>, <code>newOrderStatus</code>, * <code>limitOrderStatus</code>, <code>price</code> and <code>quantity</code>. * * @param execID unique identifier of this {@link Execution}. * @param newOrderStatus status of execution of the new order. * @param limitOrderStatus status of execution of the limit order. * @param price price of execution. * @param quantity quantity of execution. *///from w w w . j a v a2 s .c o m public Execution(final Long execID, final OrderStatus newOrderStatus, final OrderStatus limitOrderStatus, final BigDecimal price, final Long quantity) { checkNotNull(execID); checkNotNull(newOrderStatus); checkNotNull(limitOrderStatus); checkArgument(limitOrderStatus.getOrder().getOrdType().isLimit()); checkArgument( newOrderStatus.getOrder().getSide().getOpposite().equals(limitOrderStatus.getOrder().getSide())); checkNotNull(price); checkArgument(price.compareTo(Order.NO_PRICE) > 0); checkNotNull(quantity); checkArgument(Longs.compare(quantity, Order.NO_QTY) > 0); this.execID = execID; this.newOrderStatus = newOrderStatus; this.limitOrderStatus = limitOrderStatus; this.price = price; this.quantity = quantity; }
From source file:co.cask.cdap.proto.QueryInfo.java
@Override public int compareTo(QueryInfo queryInfo) { // descending. return Longs.compare(queryInfo.getTimestamp(), getTimestamp()); }