private int matchTail ( int base , int index , String key ) { int positionInTailArr = base - TAIL_OFFSET ; int keyLength = key . length ( ) ; for ( int i = 0 ; i < keyLength ; i ++ ) { if ( key . charAt ( i ) != tailBuffer . get ( positionInTailArr + i ) ) { return - 1 ; } } return tailBuffer . get ( positionInTailArr + keyLength ) == TERMINATING_CHARACTER ? index : 0 ; }
Check match in tail array