public int indexOf ( int [ ] sequence ) { int index = - 1 ; for ( int i = 0 ; index == - 1 && i <= currentSize - sequence . length ; i ++ ) { if ( buffer [ i ] == sequence [ 0 ] ) { boolean matches = true ; for ( int j = 1 ; matches && j < sequence . length ; j ++ ) { if ( buffer [ i + j ] != sequence [ j ] ) { matches = false ; } } if ( matches ) { index = i ; } } } return index ; }
finds sequence in current buffer .