You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using SlabHandle;
namespace MES.Interface
{
//禁忌树
public class TabuMapTree
{
private Dictionary<String, TabuMapTree> sonTreeMap = new Dictionary<String, TabuMapTree>();
public BP_ORDER_ITEM nodeSquare;
public void add(IList<BP_ORDER_ITEM> squareList, int index)
{
if (index >= squareList.Count)
{
return;
}
if (nodeSquare == null)
{
nodeSquare = squareList[index];
index++;
}
BP_ORDER_ITEM square = squareList[index];
string id = square.ORD_NO + square.ORD_ITEM;
if (sonTreeMap.Keys.Contains(id))
{
sonTreeMap[id].add(squareList, index + 1);
}
else
{
TabuMapTree tabuMapTree = new TabuMapTree();
tabuMapTree.nodeSquare = square;
sonTreeMap.Add(id, tabuMapTree);
//sonTreeMap[id].add(squareList, index + 1);
}
}
public bool contains(IList<BP_ORDER_ITEM> squareList, int index)
{
if (index >= squareList.Count)
{
return true;
}
BP_ORDER_ITEM square = squareList[index];
string id = square.ORD_NO;
if (sonTreeMap.Keys.Contains(id))
{
return sonTreeMap[id].contains(squareList, index + 1);
}
else
{
return false;
}
}
public void show()
{
foreach (String key in sonTreeMap.Keys)
{
String id = sonTreeMap[key].nodeSquare.ORD_NO;
sonTreeMap[key].show();
}
}
// 判断两个Squre是否相等
public bool isEq(Square square1, Square square2)
{
return square1.id.Equals(square2.id);
}
//public void show()
//{
// for (String key : sonTreeMap.keySet()) {
// String id = sonTreeMap.get(key).getNodeSquare().getId();
// sonTreeMap.get(key).show();
//}
}
}