Java Code Examples for com.google.common.primitives.UnsignedBytes#lexicographicalComparator()
The following examples show how to use
com.google.common.primitives.UnsignedBytes#lexicographicalComparator() .
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: ByteLexicoderTest.java From geowave with Apache License 2.0 | 6 votes |
public ByteLexicoderTest() { super( Lexicoders.BYTE, Byte.MIN_VALUE, Byte.MAX_VALUE, new Byte[] { (byte) -10, Byte.MIN_VALUE, (byte) 11, (byte) -122, (byte) 122, (byte) -100, (byte) 100, Byte.MAX_VALUE, (byte) 0}, UnsignedBytes.lexicographicalComparator()); }
Example 2
Source File: DoubleLexicoderTest.java From geowave with Apache License 2.0 | 6 votes |
public DoubleLexicoderTest() { super( Lexicoders.DOUBLE, -Double.MAX_VALUE, Double.MAX_VALUE, new Double[] { -10d, -Double.MAX_VALUE, 11d, -14.2, 14.2, -100.002, 100.002, -11d, Double.MAX_VALUE, 0d}, UnsignedBytes.lexicographicalComparator()); }
Example 3
Source File: TransactionMap.java From Qora with MIT License | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) protected void createIndexes(DB database) { //TIMESTAMP INDEX Tuple2Comparator<Long, byte[]> comparator = new Fun.Tuple2Comparator<Long, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator()); NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("transactions_index_timestamp") .comparator(comparator) .makeOrGet(); NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("transactions_index_timestamp_descending") .comparator(new ReverseComparator(comparator)) .makeOrGet(); createIndex(TIMESTAMP_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Long, byte[], Transaction>() { @Override public Long run(byte[] key, Transaction value) { return value.getTimestamp(); } }); }
Example 4
Source File: FloatLexicoderTest.java From geowave with Apache License 2.0 | 6 votes |
public FloatLexicoderTest() { super( Lexicoders.FLOAT, -Float.MAX_VALUE, Float.MAX_VALUE, new Float[] { -10f, -Float.MAX_VALUE, 11f, -14.2f, 14.2f, -100.002f, 100.002f, -11f, Float.MAX_VALUE, 0f}, UnsignedBytes.lexicographicalComparator()); }
Example 5
Source File: LongLexicoderTest.java From geowave with Apache License 2.0 | 5 votes |
public LongLexicoderTest() { super( Lexicoders.LONG, Long.MIN_VALUE, Long.MAX_VALUE, new Long[] {-10l, Long.MIN_VALUE, 2678l, Long.MAX_VALUE, 0l}, UnsignedBytes.lexicographicalComparator()); }
Example 6
Source File: ScriptBuilder.java From bitherj with Apache License 2.0 | 5 votes |
/** * Creates redeem script with given public keys and threshold. Given public keys will be placed in * redeem script in the lexicographical sorting order. */ public static Script createRedeemScript(int threshold, List<byte[]> pubkeys) { pubkeys = new ArrayList<byte[]>(pubkeys); final Comparator comparator = UnsignedBytes.lexicographicalComparator(); Collections.sort(pubkeys, new Comparator<byte[]>() { @Override public int compare(byte[] k1, byte[] k2) { return comparator.compare(k1, k2); } }); return ScriptBuilder.createMultiSigOutputScript(threshold, pubkeys); }
Example 7
Source File: TransactionDatabase.java From Qora with MIT License | 5 votes |
public TransactionDatabase(TransactionDatabase parent) { this.parent = parent; //OPEN MAP this.transactionMap = new TreeMap<byte[], byte[]>(UnsignedBytes.lexicographicalComparator()); }
Example 8
Source File: ByteArrayWrapperTest.java From ethereumj with MIT License | 5 votes |
@Test public void testEqualsPerformance() { boolean testEnabled = false; if(testEnabled) { final int ITERATIONS = 10000000; long start1 = System.currentTimeMillis(); for (int i = 0; i < ITERATIONS; i++) { Comparator<byte[]> comparator = UnsignedBytes .lexicographicalComparator(); comparator.compare(wrapper1.getData(), wrapper2.getData()); } System.out.println(System.currentTimeMillis() - start1 + "ms"); long start2 = System.currentTimeMillis(); for (int i = 0; i < ITERATIONS; i++) { Arrays.equals(wrapper1.getData(), wrapper2.getData()); } System.out.println(System.currentTimeMillis() - start2 + "ms"); long start3 = System.currentTimeMillis(); for (int i = 0; i < ITERATIONS; i++) { FastByteComparisons.compareTo(wrapper1.getData(), 0, wrapper1.getData().length, wrapper2.getData(), 0, wrapper1.getData().length); } System.out.println(System.currentTimeMillis() - start3 + "ms"); } }
Example 9
Source File: ShortLexicoderTest.java From geowave with Apache License 2.0 | 5 votes |
public ShortLexicoderTest() { super( Lexicoders.SHORT, Short.MIN_VALUE, Short.MAX_VALUE, new Short[] {(short) -10, Short.MIN_VALUE, (short) 2678, Short.MAX_VALUE, (short) 0}, UnsignedBytes.lexicographicalComparator()); }
Example 10
Source File: WriteFence.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void startTx(Transaction tx) { this.tx = tx; if (inProgressChanges == null) { inProgressChanges = new TreeSet<>(UnsignedBytes.lexicographicalComparator()); for (long inProgressTx : tx.getInProgress()) { inProgressChanges.add(Bytes.concat(fenceId, Longs.toByteArray(inProgressTx))); } } }
Example 11
Source File: ChildMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], byte[]> getMemoryMap() { return new TreeMap<byte[], byte[]>(UnsignedBytes.lexicographicalComparator()); }
Example 12
Source File: Subnet.java From dhcp4j with Apache License 2.0 | 4 votes |
public boolean rangeContains(@Nonnull byte[] address) { Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator(); return (comparator.compare(address, getRangeStart().getAddress()) >= 0) && (comparator.compare(address, getRangeEnd().getAddress()) <= 0); }
Example 13
Source File: IssueAssetMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], Long> getMemoryMap() { return new TreeMap<byte[], Long>(UnsignedBytes.lexicographicalComparator()); }
Example 14
Source File: BlockMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], Block> getMemoryMap() { return new TreeMap<byte[], Block>(UnsignedBytes.lexicographicalComparator()); }
Example 15
Source File: TransactionParentMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], byte[]> getMemoryMap() { return new TreeMap<byte[], byte[]>(UnsignedBytes.lexicographicalComparator()); }
Example 16
Source File: VoteOnPollMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], Integer> getMemoryMap() { return new TreeMap<byte[], Integer>(UnsignedBytes.lexicographicalComparator()); }
Example 17
Source File: PeerMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], byte[]> getMemoryMap() { return new TreeMap<byte[], byte[]>(UnsignedBytes.lexicographicalComparator()); }
Example 18
Source File: Subnet.java From dhcp4j with Apache License 2.0 | 4 votes |
public boolean rangeContains(@Nonnull byte[] address) { Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator(); return (comparator.compare(address, getRangeStart().getAddress()) >= 0) && (comparator.compare(address, getRangeEnd().getAddress()) <= 0); }
Example 19
Source File: UpdateNameMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], Name> getMemoryMap() { return new TreeMap<byte[], Name>(UnsignedBytes.lexicographicalComparator()); }
Example 20
Source File: TransactionMap.java From Qora with MIT License | 4 votes |
@Override protected Map<byte[], Transaction> getMemoryMap() { return new TreeMap<byte[], Transaction>(UnsignedBytes.lexicographicalComparator()); }