public PeterParker(PeterParker parent, ParkingType type) { parkings = new List <Parking>(parent.parkings); parkings.Add(new Parking(type)); totalLength = parent.totalLength; //baseCurve = parent.baseCurve; }
public void Add(PeterParker parker) { if (collection.Count < 10) { collection.Add(parker); Sort(); } else { if (collection[0].ParkingUnitCount().Sum() < parker.ParkingUnitCount().Sum()) { collection.RemoveAt(0); collection.Add(parker); Sort(); } } }
public static ParkingResult Calculate(double initialLength, double coreDepth, ParkingLineType lineType) { PeterParker origin = new PeterParker(initialLength /*, initialCurve*/); Queue <PeterParker> wait = new Queue <PeterParker>(); PeterParkerCollection fit = new PeterParkerCollection(); wait.Enqueue(origin); List <ParkingType> parkingTypeSelected = new List <ParkingType>(); switch (lineType) { case ParkingLineType.Default: parkingTypeSelected = new double[] { 0, 1, 2, 3, 4, 5, 6, 7 }.Select(n => (ParkingType)n).ToList(); break; case ParkingLineType.DoubleLine: parkingTypeSelected = new double[] { 1, 3, 5, 7 }.Select(n => (ParkingType)n).ToList(); break; case ParkingLineType.PerpOnly: parkingTypeSelected = new double[] { 6, 7 }.Select(n => (ParkingType)n).ToList(); break; case ParkingLineType.SingleLine: parkingTypeSelected = new double[] { 0, 2, 4, 6 }.Select(n => (ParkingType)n).ToList(); break; case ParkingLineType.SingleOneline: parkingTypeSelected = new double[] { 0, 2, 4, 6 }.Select(n => (ParkingType)n).ToList(); break; default: break; } double leftLengthLimit = 5000; //bool isFirst = true; while (wait.Count > 0) { PeterParker current = wait.Dequeue(); for (int i = 0; i < (int)ParkingType.Max; i++) { if (lineType == ParkingLineType.Default || lineType == ParkingLineType.SingleOneline) { if ((current.LeftLength() == current.totalLength) && coreDepth > new Parking((ParkingType)i).height) { continue; } } //주차 타입 필터 if (!parkingTypeSelected.Contains((ParkingType)i)) { continue; } PeterParker temp = new PeterParker(current, (ParkingType)i); if (temp.LeftLength() < 0) { //cull } else if (temp.LeftLength() > 0) { if (temp.LeftLength() < leftLengthLimit) { //fit fit.Add(temp); } else { //re enqueue wait.Enqueue(temp); } } } //isFirst = false; } // fit.collection.ForEach(n => n.FillRoads()); var result = new ParkingResult(fit); return(result); }