method to print some stats for a tree
This commit is contained in:
24
pdb-utils/src/main/java/org/lucares/utils/ArrayUtils.java
Normal file
24
pdb-utils/src/main/java/org/lucares/utils/ArrayUtils.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package org.lucares.utils;
|
||||
|
||||
public class ArrayUtils {
|
||||
public static int findFirst(final byte[] bytes, final byte key) {
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if (bytes[i] == key) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int countConsecutive(final byte[] bytes, final byte key, final int offset) {
|
||||
int count = 0;
|
||||
for (int i = offset; i < bytes.length; i++) {
|
||||
if (bytes[i] == key) {
|
||||
count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user