using System.Collections.Generic;
///
/// 火场信息中到场力量数据
///
public class PowerPresentData
{
public static readonly PowerPresentData Instance = new PowerPresentData();
//按中队、车类型组织车辆数据(string:组织机构;List:某类型车有多少辆)
private Dictionary>> mOrgCars =
new Dictionary>>();
public void AddPresentCar(KeyValuePair>> presentCar)
{
List> typePresentCars = new List>();
if (mOrgCars.TryGetValue(presentCar.Key, out typePresentCars))
{
foreach (KeyValuePair item in presentCar.Value)
{
AddCar(typePresentCars,item, presentCar.Key);
}
}
else
{
mOrgCars.Add(presentCar.Key, presentCar.Value);
}
}
public void AddCar(List> typePresentCars, KeyValuePair car, string orgName)
{
for (int i=0;i< typePresentCars.Count;i++)
{
if (typePresentCars[i].Key.TypeName == car.Key.TypeName)
{
typePresentCars[i] = new KeyValuePair(typePresentCars[i].Key,typePresentCars[i].Value + car.Value);
}
}
List keys = new List();
foreach (KeyValuePair item in typePresentCars)
{
keys.Add(item.Key.TypeName);
}
if (!keys.Contains(car.Key.TypeName))
{
typePresentCars.Add(car);
}
}
///
/// 得到所有到场力量
///
///
public Dictionary>> GetAllPresentCar()
{
return mOrgCars;
}
}