- Timestamp:
- 05/04/13 17:51:14 (12 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/PackingDimensions.cs
r9348 r9440 37 37 /// </summary> 38 38 public Int32 AssignedBin { get; set; } 39 /// <summary> 40 /// Determins if the positioned item is to be rotate by 90 degrees or not. 41 /// </summary> 42 public Boolean Rotated { get; set; } 39 43 40 44 [StorableConstructor] … … 43 47 : base(original, cloner) { 44 48 AssignedBin = original.AssignedBin; 49 Rotated = original.Rotated; 45 50 } 46 51 47 public PackingDimensions(Int32 assignedBin ) {52 public PackingDimensions(Int32 assignedBin, Boolean rotated) { 48 53 this.AssignedBin = assignedBin; 54 this.Rotated = rotated; 49 55 } 50 56 … … 52 58 StringBuilder sb = new StringBuilder(); 53 59 sb.Append("["); 54 sb.Append( "AssignedBin:");55 sb.Append( AssignedBin);60 sb.Append(AssignedBin + "-"); 61 sb.Append(Rotated); 56 62 sb.Append("]"); 57 63 return sb.ToString(); 58 64 } 65 66 public override bool Equals(object obj) { 67 var pd = obj as PackingDimensions; 68 if (pd != null) 69 return (pd.AssignedBin == this.AssignedBin && pd.Rotated == this.Rotated); 70 else return false; 71 } 72 73 public override int GetHashCode() { 74 return 31 * AssignedBin * (Rotated ? 3 : 7); 75 } 59 76 } 60 77 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/ThreeDimensionalPacking.cs
r9348 r9440 49 49 } 50 50 51 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z) : base(assignedBin) { 51 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z) : this(assignedBin, x, y, z, false) {} 52 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z, bool rotated) 53 : base(assignedBin, rotated) { 52 54 this.X = x; 53 55 this.Y = y; … … 67 69 return sb.ToString(); 68 70 } 71 72 73 public override bool Equals(object obj) { 74 var tdp = obj as ThreeDimensionalPacking; 75 if (tdp != null) 76 return (tdp.X == this.X && tdp.Y == this.Y && tdp.Z == this.Z); 77 else return false; 78 } 79 80 public override int GetHashCode() { 81 return base.GetHashCode() + 13 * X + 17 * Y + 23 * Z; 82 } 69 83 } 70 84 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/TwoDimensionalPacking.cs
r9348 r9440 45 45 public override IDeepCloneable Clone(Cloner cloner) { 46 46 return new TwoDimensionalPacking(this, cloner); 47 } 47 } 48 48 49 public TwoDimensionalPacking(int assignedBin, int x, int y) : base(assignedBin) { 49 public TwoDimensionalPacking(int assignedBin, int x, int y) : this(assignedBin, x, y, false) { } 50 public TwoDimensionalPacking(int assignedBin, int x, int y, bool rotated) 51 : base(assignedBin, rotated) { 50 52 this.X = x; 51 53 this.Y = y; … … 63 65 return sb.ToString(); 64 66 } 67 68 69 public override bool Equals(object obj) { 70 var tdp = obj as TwoDimensionalPacking; 71 if (tdp != null) 72 return (tdp.X == this.X && tdp.Y == this.Y); 73 else return false; 74 } 75 76 public override int GetHashCode() { 77 return base.GetHashCode() + 13 * X + 17 * Y; 78 } 65 79 } 66 80 }
Note: See TracChangeset
for help on using the changeset viewer.