本文整理汇总了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);
//.........这里部分代码省略.........