我想将arraylist的每个项目与另一个arrayList的项目进行比较它似乎很慢。 如何加速这段代码。 我希望char通过每个字符串的char比较。
如果此处不需要任何循环,请建议我。
public static void FinalGroups(ArrayList<ArrayList<QuineMCCluskyModel>> Prime_Implicants,
ArrayList<ArrayList<QuineMCCluskyModel>> FinalGRoupImplicants)
{
Integer count = 0;
for (Integer i = 0; i < Prime_Implicants.size(); i++)
{
for (Integer j = 0; j < Prime_Implicants.get(i).size(); j++)
{
if (i + 1 < Prime_Implicants.size())
for (Integer L = 0; L < Prime_Implicants.get(i+1).size(); L++)
{
count = 0;
if (Prime_Implicants.get(i).size() > 0 && Prime_Implicants.get(i+1).size() > 0)
{
for (Integer k = 0; k < Prime_Implicants.get(i).get(j).Number.length() ; k++)
{
if (Prime_Implicants.get(i).get(j).Number.charAt(k)
!= Prime_Implicants.get(i+1).get(L).Number.charAt(k))
{
count++;
}
}
if (count == 1)
{
while (i + 1 > FinalGRoupImplicants.size())
FinalGRoupImplicants.add(new ArrayList<QuineMCCluskyModel>());
QuineMCCluskyModel temp_model = new QuineMCCluskyModel();
temp_model.Number = "";
temp_model.HasUsed = false;
for (Integer k = 0; k < Prime_Implicants.get(i).get(j).Number.length()
; k++)
{
if (Prime_Implicants.get(i).get(j).Number.charAt(k)
== Prime_Implicants.get(i+1).get(L).Number.charAt(k))
{
temp_model.Number += Prime_Implicants.get(i).get(j).Number.charAt(k);
}
else
{
temp_model.Number += 'b';
}
}
Prime_Implicants.get(i).get(j).HasUsed = true;
Prime_Implicants.get(i+1).get(L).HasUsed = true;
}
}
}
}
}