A general analysis of change-point methods