l += line.getLength();
l.add(line.getLength());
    public TrainPath truncateTail (int newLength) {	ListIterator i = segments.listIterator(0);	double l = 0;	IntLine line = null;	LinkedList removedSegments = new LinkedList(); 	while (i.hasNext() && l < newLength) {	    line = (IntLine) i.next();	    l += line.getLength();	}	while (i.hasNext()) {	    removedSegments.add(i.next());	    i.remove();	}	if (l > newLength) {	    int oldX2 = line.x2;	    int oldY2 = line.y2;	    line.setLength(line.getLength() - (l - newLength));	    removedSegments.addFirst(new IntLine(line.x2, line.y2, oldX2,		       oldY2));	}	length = newLength;	return new TrainPath((IntLine[]) removedSegments.toArray(new		    IntLine[removedSegments.size()]));    }