question: private int findMarkerSegmentPosition ( Class cls , boolean first ) { if ( first ) { ListIterator iter = markerSequence . listIterator ( ) ; for ( int i = 0 ; iter . hasNext ( ) ; i ++ ) { MarkerSegment seg = ( MarkerSegment ) iter . next ( ) ; if ( cls . isInstance ( seg ) ) { return i ; } } } else { ListIterator iter = markerSequence . listIterator ( markerSequence . size ( ) ) ; for ( int i = markerSequence . size ( ) - 1 ; iter . hasPrevious ( ) ; i -- ) { MarkerSegment seg = ( MarkerSegment ) iter . previous ( ) ; if ( cls . isInstance ( seg ) ) { return i ; } } } return - 1 ; }
target:  Returns the index of the first or last MarkerSegment in the list of the given class, or -1 if none is found.