/// <summary> /// Checks the traffic light plan and adds it to the list, if there is no plan for this traffic light /// or swaps it with the old plan of this traffic light. /// </summary> /// <param name="plans"></param> public static void AddTrafficLightPlans(List <TrafficLightPlan> plans) { foreach (TrafficLightPlan plan in plans) { TrafficLightPlan p = FindTrafficLightPlan(plan.LightId); if (p == null) //if there is no plan for this traffic light { trafficLightPlans.Add(plan); } else //if there is already a plan { RemoveTrafficLightPlan(p); trafficLightPlans.Add(plan); } } }
/// <summary> /// Removes the TrafficLightPlan from the list of plans. Returns true in case of success. /// </summary> /// <param name="plan">The TrafficLightPlan which needs to be removed.</param> /// <returns></returns> public static bool RemoveTrafficLightPlan(TrafficLightPlan plan) { return(trafficLightPlans.Remove(plan)); }