Android Utililty Methods Array Search

List of utility methods to do Array Search

Description

The list of methods to do Array Search are organized into topic(s).

Method

booleaninArray(Object o, Object... arr)
in Array
for (Object object : arr) {
    if (o == object)
        return true;
return false;
intindexOf(byte[] bytes, byte[] pattern, int start)
Calculate the index of the first occurrence of the pattern in the byte array, starting with the given index.
if (pattern.length == 0) {
    return start;
if (start > bytes.length) {
    return -1;
int last = bytes.length - pattern.length + 1;
next: for (; start < last; start++) {
...
intindexOf(byte[] data, byte search)
index Of
int len = data.length;
for (int i = 0; i < len; i++) {
    if (data[i] == search) {
        return i;
return -1;
intindexof(byte[] shortBytes, byte[] longBytes)
indexof
for (int i = 0; i < longBytes.length; i++) {
    if (longBytes[i] == shortBytes[0]
            && longBytes.length - i >= shortBytes.length) {
        boolean isIndexof = true;
        for (int j = 1; j < shortBytes.length; j++) {
            if (shortBytes[j] != longBytes[i + j]) {
                isIndexof = false;
                continue;
...