Here you can find the source of lastIndexOf(final byte[] reference, final byte[] query)
Parameter | Description |
---|---|
reference | the reference sequence |
query | the query sequence |
public static int lastIndexOf(final byte[] reference, final byte[] query)
//package com.java2s; //License from project: Open Source License public class Main { /**//w w w .ja v a2s . c om * Find the last occurrence of the query sequence in the reference sequence * * Returns the index of the last occurrence or -1 if the query sequence is not found * * @param reference the reference sequence * @param query the query sequence */ public static int lastIndexOf(final byte[] reference, final byte[] query) { int queryLength = query.length; // start search from the last possible matching position and search to the left for (int r = reference.length - queryLength; r >= 0; r--) { int q = 0; while (q < queryLength && reference[r + q] == query[q]) { q++; } if (q == queryLength) { return r; } } return -1; } }