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;
}

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 ; }
returns the index of the first or last markersegment in the list of the given class , or - 1 if none is found .
