Java ByteBuffer Search indexOf(ByteBuffer buffer, byte b)

Here you can find the source of indexOf(ByteBuffer buffer, byte b)

Description

index Of

License

Open Source License

Declaration

public static int indexOf(ByteBuffer buffer, byte b) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    public static int indexOf(ByteBuffer buffer, byte b) {
        return indexOf(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining(), b);
    }//from www.j  a  v a 2 s .co  m

    public static int indexOf(byte[] data, byte b) {
        return indexOf(data, 0, data.length, b);
    }

    public static int indexOf(byte[] data, int offset, int length, byte b) {
        int idx = -1;

        for (int i = offset; i < offset + length; i++) {
            if (data[i] == b) {
                idx = i;
                break;
            }
        }

        return idx;
    }
}

Related

  1. binarySearch(ByteBuffer[] cells, ByteBuffer key, Comparator order)
  2. indexOf(ByteBuffer buf, byte b)
  3. indexOf(ByteBuffer buf, byte value)
  4. indexOf(ByteBuffer buffer, ByteBuffer pattern)
  5. indexOf(ByteBuffer buffer, ByteBuffer pattern)
  6. indexOf(final ByteBuffer buf, final int c, final int start, final int end)
  7. indexOf(final ByteBuffer haystack, byte[] needle)