当前位置: 首页>>代码示例>>C#>>正文


C# School.Clone方法代码示例

本文整理汇总了C#中School.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# School.Clone方法的具体用法?C# School.Clone怎么用?C# School.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在School的用法示例。


在下文中一共展示了School.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: activateSchedule

        private void activateSchedule(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show("Currently does nothing.");
            startGrid.Visibility = Visibility.Hidden;
            scheduleSaveGrid.Visibility = Visibility.Visible;
            startGrid.IsEnabled = false;
            scheduleSaveGrid.IsEnabled = true;
            Student[, ,] schedule = new Student[weekLength, daySlots, slots];
            School[,] schoolBlock = new School[weekLength, daySlots];
            Student[, ,] scheduleCopy;
            School[,] schoolBlockCopy;
            int daypos = 0;
            int weekpos = 0;
            int slot = 0;
            schoolBlock[0, 0] = schools[0];
            foreach (School ack in schools)
            {
                foreach (Student otto in ack.attending)
                {
                    int max = otto.blocks * otto.slotsPerSession;
                    for (int copier = 0; copier < max; ++copier)
                    {
                        schedule[weekpos, daypos, slot] = otto;
                        schoolBlock[weekpos, daypos] = ack;

                        if (slot < slots - 1)
                            ++slot;
                        else
                        {
                            slot = 0;

                            if (daypos < daySlots - 1)
                            {
                                ++daypos;

                            }
                            else
                            {

                                daypos = 0;
                                if (weekpos < weekLength - 1)
                                    ++weekpos;
                                else
                                    MessageBox.Show("There are not enough slots to put students in.");
                            }
                        }
                    }
                }
                if (daypos < daySlots - 1)
                {
                    ++daypos;

                }
                else
                {
                    daypos = 0;
                    if (weekpos < weekLength - 1)
                        ++weekpos;
                    else
                        MessageBox.Show("There are not enough slots to put students in.");

                }
            }
            schoolBlockCopy = (School[,])schoolBlock.Clone();
            scheduleCopy = (Student[, ,])schedule.Clone();
            int oldCost = costCalc(schedule, schoolBlock);
            int newCost;
            double sup = Math.Log(oldCost, 2);
            int prob = (int)sup;
            double lastCost = oldCost;
            int ite = 0;
            while (prob > 0)
            {
                System.Console.WriteLine("proceeding...");
                if (oldCost < lastCost)
                {
                    prob = (int)(sup * Math.Pow(1023.0 / 1024, ite) * oldCost / lastCost);
                    schoolBlockCopy = (School[,])schoolBlock.Clone();
                    scheduleCopy = (Student[, ,])schedule.Clone();
                    System.Console.WriteLine(oldCost);
                    ++ite;
                }
                else
                {
                    oldCost = (int)lastCost;
                    schoolBlock = schoolBlockCopy;
                    schedule = scheduleCopy;
                }
                for (int iter = 0; iter < 1000; ++iter)
                {
                    int swapADay, swapBDay, swapAWeek, swapBWeek, swapASlot, swapBSlot;
                    //I have a preference for having the continue part of a loop be a true bool.
                    bool didNotGo = true;
                    while (didNotGo)
                    {
                        bool Anull, Bnull;

                        swapADay = gigi.Next(daySlots);
                        swapBDay = gigi.Next(daySlots);
                        swapAWeek = gigi.Next(weekLength);
//.........这里部分代码省略.........
开发者ID:catzilla4,项目名称:School-Therapist-Scheduling,代码行数:101,代码来源:MainWindow.xaml.cs


注:本文中的School.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。