mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 22:58:32 +01:00
Utils: Remove reverseDwordBytes(), it wasn't used.
This commit is contained in:
parent
4300b2ee40
commit
8295afc03b
2 changed files with 0 additions and 29 deletions
|
@ -174,27 +174,6 @@ public class Utils {
|
|||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the given byte array with the bytes of each double-word (4 bytes) reversed.
|
||||
*
|
||||
* @param bytes length must be divisible by 4.
|
||||
* @param trimLength trim output to this length. If positive, must be divisible by 4.
|
||||
*/
|
||||
public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) {
|
||||
checkArgument(bytes.length % 4 == 0);
|
||||
checkArgument(trimLength < 0 || trimLength % 4 == 0);
|
||||
|
||||
byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length];
|
||||
|
||||
for (int i = 0; i < rev.length; i += 4) {
|
||||
System.arraycopy(bytes, i, rev, i , 4);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
rev[i + j] = bytes[i + 3 - j];
|
||||
}
|
||||
}
|
||||
return rev;
|
||||
}
|
||||
|
||||
/** Parse 4 bytes from the byte array (starting at the offset) as unsigned 32-bit integer in little endian format. */
|
||||
public static long readUint32(byte[] bytes, int offset) {
|
||||
return (bytes[offset] & 0xffl) |
|
||||
|
|
|
@ -33,14 +33,6 @@ public class UtilsTest {
|
|||
assertArrayEquals(new byte[]{1, 2, 3, 4, 5}, Utils.reverseBytes(new byte[]{5, 4, 3, 2, 1}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReverseDwordBytes() {
|
||||
assertArrayEquals(new byte[]{1, 2, 3, 4, 5, 6, 7, 8}, Utils.reverseDwordBytes(new byte[]{4, 3, 2, 1, 8, 7, 6, 5}, -1));
|
||||
assertArrayEquals(new byte[]{1, 2, 3, 4}, Utils.reverseDwordBytes(new byte[]{4, 3, 2, 1, 8, 7, 6, 5}, 4));
|
||||
assertArrayEquals(new byte[0], Utils.reverseDwordBytes(new byte[]{4, 3, 2, 1, 8, 7, 6, 5}, 0));
|
||||
assertArrayEquals(new byte[0], Utils.reverseDwordBytes(new byte[0], 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxOfMostFreq() throws Exception {
|
||||
assertEquals(0, Utils.maxOfMostFreq());
|
||||
|
|
Loading…
Add table
Reference in a new issue