示例#1
0
        private List <int>[] GetAllowedItems(SkyscrapersNxNDataObject data)
        {
            bool[][] existing = new bool[_n][];
            for (int i = 0; i < _n; i++)
            {
                existing[i] = new bool[_n];
            }

            foreach (int ix in data.Idx)
            {
                for (int i = 0; i < _n; i++)
                {
                    existing[i][data.PrecalcData[ix][i] - 1] = true;
                }
            }

            List <int>[] res = new List <int> [_n];
            for (int i = 0; i < _n; i++)
            {
                List <int> l = new List <int>();
                res[i] = l;
                for (int j = 0; j < _n; j++)
                {
                    if (existing[i][j])
                    {
                        l.Add(j + 1);
                    }
                }
            }
            return(res);
        }
示例#2
0
        private bool CheckListsAndFindShortest(SkyscraperNxNDataLists dataLists, out int shortestIndex)
        {
            shortestIndex = -1;
            int currLen = int.MaxValue;

            for (int i = 0; i < dataLists.Lists.Length; i++)
            {
                if (dataLists.Lists[i] == null)
                {
                    continue;
                }
                SkyscrapersNxNDataObject list = dataLists.Lists[i];
                if (list.Idx.Count == 0)
                {
                    return(false);
                }
                if ((list.Idx.Count > 1) && (list.Idx.Count < currLen))
                {
                    currLen       = list.Idx.Count;
                    shortestIndex = i;
                }
            }

            return(true);
        }
        public SkyscraperNxNDataLists(SkyscraperNxNDataLists src)
        {
            Lists = new SkyscrapersNxNDataObject[src.Lists.Length];  //tablica list zainicjalizowana nulami

            //skopiowanie list ze zrodla
            for (int i = 0; i < src.Lists.Length; i++)
            {
                if (src.Lists[i] != null)
                {
                    Lists[i] = new SkyscrapersNxNDataObject(src.Lists[i]);
                }
            }
        }
        public SkyscraperNxNDataLists(int[] constraints, int n, SkyscrapersPrecalcData precalc)
        {
            Lists = new SkyscrapersNxNDataObject[4 * n];  //tablica list zainicjalizowana nulami

            //zainicjalizowanie list dla wszystkich ograniczen
            for (int i = 0; i < Lists.Length; i++)
            {
                if (constraints[i] != 0)
                {
                    Lists[i] = new SkyscrapersNxNDataObject(precalc.GetList(constraints[i]));
                }
            }
        }
示例#5
0
 public SkyscrapersNxNDataObject(SkyscrapersNxNDataObject src)
 {
     PrecalcData = src.PrecalcData;
     Idx         = src.Idx.ToList();
 }