public ComponentState bestFit(Collection<ComponentState> states) { ComponentState bestFit = null; int bestFitValue = 0; for (ComponentState state : states) { if (this.isActive() != state.isActive()) continue; int currFitValue = state.fitValue(this) + this.fitValue(state); if (bestFit == null) { bestFit = state; bestFitValue = currFitValue; } else { if (currFitValue > bestFitValue) { bestFit = state; bestFitValue = currFitValue; } } } // fit value must be positive if (bestFitValue > 0) return bestFit; return null; }
public ComponentState bestFit(Collection<ComponentState> states) { ComponentState bestFit = null; int bestFitValue = 0; for (ComponentState state : states) { if (this.isActive() != state.isActive()) continue; int currFitValue = state.fitValue(this) + this.fitValue(state); if (bestFit == null) { bestFit = state; bestFitValue = currFitValue; } else { if (currFitValue > bestFitValue) { bestFit = state; bestFitValue = currFitValue; } } } // fit value must be positive if (bestFitValue > 0) return bestFit; return null; }