示例#1
0
        public IAutomatikusanBeoszthato[] BeoszthatokTombje()
        {
            // tömb méretének meghatározása
            int  db = 0;
            Elem p  = fej;

            while (p != null)
            {
                if (p.Tartalom is IAutomatikusanBeoszthato)
                {
                    db++;
                }
                p = p.Kovetkezo;
            }

            // tömbbe másolás
            IAutomatikusanBeoszthato[] vissza = new IAutomatikusanBeoszthato[db];

            int i = 0;

            p = fej;
            while (p != null)
            {
                if (p.Tartalom is IAutomatikusanBeoszthato)
                {
                    vissza[i++] = p.Tartalom as IAutomatikusanBeoszthato;
                }
                p = p.Kovetkezo;
            }

            return(vissza);
        }
示例#2
0
文件: Beoszto.cs 项目: sourcell/OE
        public static IAutomatikusanBeoszthato[] Beosztas(TevekenysegLista lista, DateTime nap)
        {
            IAutomatikusanBeoszthato[] tomb   = lista.BeoszthatokTombje();
            IAutomatikusanBeoszthato[] vissza = new IAutomatikusanBeoszthato[0];

            if (tomb.Length > 0)
            {
                int szabadPercek = (int)lista.SzabadPercekSzama(nap);

                bool[] E   = new bool[tomb.Length];
                bool[] OPT = new bool[tomb.Length];

                Backtrack(tomb, 0, E, OPT, szabadPercek);

                // beosztott tevékenységek feltöltése a kimeneti tömbbe
                int db = 0;
                foreach (var item in OPT)
                {
                    if (item)
                    {
                        db++;
                    }
                }

                vissza = new IAutomatikusanBeoszthato[db];

                db = 0;
                for (int i = 0; i < tomb.Length; i++)
                {
                    if (OPT[i])
                    {
                        vissza[db++] = tomb[i];
                    }
                }
            }

            return(vissza);
        }