using System;
using ;
using ;
using ;
namespace algorithm
{
public static class algorithm
{
/// <summary>
/// Descartes multiplying product
/// </summary>
public static List<List<T>> CartesianProduct<T>(this List<List<T>> lstSplit)
{
int count = 1;
(item => count *= );
//count = (1, (result, next) => result * );
var lstResult = new List<List<T>>();
for (int i = 0; i < count; ++i)
{
var lstTemp = new List<T>();
int j = 1;
(item =>
{
j *= ;
(item[(i / (count / j)) % ]);
});
(lstTemp);
}
return lstResult;
}
}
class Program
{
public static void Main()
{
StringDemo();
Generate the Demo() of Routing based on Sector;
Generate Demo2() of Routing based on Sector;
}
/// <summary>
/// Simple string Cartesian multiplication product
/// </summary>
private static void StringDemo()
{
var lstSource = new List<List<string>>
{
new List<string>() { "A","B","C"},
new List<string>() { "D","E","F"},
new List<string>() { "G","H","I"},
};
var sw = new Stopwatch();
();
var lstResult = ();
();
}
private static void generates a Demo() of Routing based on Sector
{
//By default, multiple BookingClass are allowed to be entered, which means that any one is OK.
var lstSectorDef = new List<Sector>
{
new Sector{ SeqNO=1, BookingClass="A/A1/A2"},
new Sector{ SeqNO=2, BookingClass="B/B1/B2"},
new Sector{ SeqNO=3, BookingClass="C/C1/C2"},
//.....The quantity is uncertain
};
var sw = new Stopwatch();
();
var lstSectorGroup = new List<List<Sector>>();
(item =>
{
var lstSector = new List<Sector>();
foreach (var bookingClass in ('/'))
{
var sector = ();
= bookingClass;
(sector);
}
(lstSector);
});
var lstRouting = ();
();
}
private static void generates the Demo2() of Routing based on Sector
{
//By default, multiple BookingClass are allowed to be entered, which means that any one is OK.
var lstSectorDef = new List<Sector>
{
new Sector{ SeqNO=1, BookingClass="A1/A2/A3"},
new Sector{ SeqNO=2, BookingClass="B1/B2/B3"},
new Sector{ SeqNO=3, BookingClass="C1/C2/C3"},
//.....The quantity is uncertain
};
var sw = new Stopwatch();
();
var lstTemp = new List<List<string>>();
(item =>
{
(('/').ToList());
});
var lstBookingClassGroup = ();
var lstRouting = new List<List<Sector>>();
for (int i = 0; i < ; i++)
{
var lstSector = new List<Sector>();
for (int j = 0; j < ; j++)
{
var sector = lstSectorDef[j].Clone();
= lstBookingClassGroup[i][j];
(sector);
}
(lstSector);
}
();
}
}
[DebuggerDisplay("Sector:SeqNO={SeqNO},BookingClass={BookingClass}")]
public class Sector
{
public int SeqNO { get; set; }
public string BookingClass { get; set; }
public Sector Clone()
{
return () as Sector;
}
}
}