private int linearSearch ( int position ) { int [ ] minSeqIndex = getMinSequenceIndex ( ) ; int [ ] maxSeqIndex = getMaxSequenceIndex ( ) ; int length = minSeqIndex . length ; for ( int i = 0 ; i < length ; i ++ ) { if ( position >= minSeqIndex [ i ] && position <= maxSeqIndex [ i ] ) { return i ; } } throw new IndexOutOfBoundsException ( "Given position " + position + " does not map into this Sequence" ) ; }
Scans through the sequence index arrays in linear time . Not the best performance but easier to code