minpq in java is really elegant