fix unused return
This commit is contained in:
		
							parent
							
								
									316f241193
								
							
						
					
					
						commit
						2b1a59e963
					
				
					 3 changed files with 70 additions and 56 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								output.pdf
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								output.pdf
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -1,4 +1,13 @@
 | 
				
			||||||
"use strict";
 | 
					"use strict";
 | 
				
			||||||
 | 
					var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
 | 
				
			||||||
 | 
					    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 | 
				
			||||||
 | 
					    return new (P || (P = Promise))(function (resolve, reject) {
 | 
				
			||||||
 | 
					        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 | 
				
			||||||
 | 
					        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 | 
				
			||||||
 | 
					        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 | 
				
			||||||
 | 
					        step((generator = generator.apply(thisArg, _arguments || [])).next());
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
					Object.defineProperty(exports, "__esModule", { value: true });
 | 
				
			||||||
exports.BreakLineAlgorithm = void 0;
 | 
					exports.BreakLineAlgorithm = void 0;
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -72,6 +81,7 @@ class BreakLineAlgorithm {
 | 
				
			||||||
     * check all the total cost of paragraphes of the segnemt
 | 
					     * check all the total cost of paragraphes of the segnemt
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    totalCost(items, lineWidth) {
 | 
					    totalCost(items, lineWidth) {
 | 
				
			||||||
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            let lineWidthFixed = lineWidth * 0.75;
 | 
					            let lineWidthFixed = lineWidth * 0.75;
 | 
				
			||||||
            let itemsLength = items.length;
 | 
					            let itemsLength = items.length;
 | 
				
			||||||
            this.lineCostStorage = Array(itemsLength);
 | 
					            this.lineCostStorage = Array(itemsLength);
 | 
				
			||||||
| 
						 | 
					@ -81,8 +91,8 @@ class BreakLineAlgorithm {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            this.totalCostAuxStorage = Array(itemsLength).fill(null);
 | 
					            this.totalCostAuxStorage = Array(itemsLength).fill(null);
 | 
				
			||||||
            let a = Infinity;
 | 
					            let a = Infinity;
 | 
				
			||||||
        for (var k = itemsLength - 2; this.lineCost(items, k + 1, itemsLength - 1, lineWidthFixed) < Infinity; k--) {
 | 
					            for (var k = itemsLength - 2; (yield this.lineCost(items, k + 1, itemsLength - 1, lineWidthFixed)) < Infinity; k--) {
 | 
				
			||||||
            let tmp = this.totalCostAux(items, k, lineWidthFixed);
 | 
					                let tmp = yield this.totalCostAux(items, k, lineWidthFixed);
 | 
				
			||||||
                if (a > tmp) {
 | 
					                if (a > tmp) {
 | 
				
			||||||
                    this.prevNodes[itemsLength - 1] = k;
 | 
					                    this.prevNodes[itemsLength - 1] = k;
 | 
				
			||||||
                    a = tmp;
 | 
					                    a = tmp;
 | 
				
			||||||
| 
						 | 
					@ -91,6 +101,7 @@ class BreakLineAlgorithm {
 | 
				
			||||||
            console.log("~~~", lineWidth);
 | 
					            console.log("~~~", lineWidth);
 | 
				
			||||||
            console.log(items[itemsLength - 2]);
 | 
					            console.log(items[itemsLength - 2]);
 | 
				
			||||||
            return a;
 | 
					            return a;
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * check the total cost item[0..j].
 | 
					     * check the total cost item[0..j].
 | 
				
			||||||
| 
						 | 
					@ -99,10 +110,11 @@ class BreakLineAlgorithm {
 | 
				
			||||||
     * @param lineWidth
 | 
					     * @param lineWidth
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    totalCostAux(items, j, lineWidth) {
 | 
					    totalCostAux(items, j, lineWidth) {
 | 
				
			||||||
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            if (this.totalCostAuxStorage[j] !== null) {
 | 
					            if (this.totalCostAuxStorage[j] !== null) {
 | 
				
			||||||
                return this.totalCostAuxStorage[j];
 | 
					                return this.totalCostAuxStorage[j];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        let rawLineCost = this.lineCost(items, 0, j, lineWidth);
 | 
					            let rawLineCost = yield this.lineCost(items, 0, j, lineWidth);
 | 
				
			||||||
            if (rawLineCost != Infinity) {
 | 
					            if (rawLineCost != Infinity) {
 | 
				
			||||||
                this.totalCostAuxStorage[j] = rawLineCost ** 3.0;
 | 
					                this.totalCostAuxStorage[j] = rawLineCost ** 3.0;
 | 
				
			||||||
                return rawLineCost ** 3.0;
 | 
					                return rawLineCost ** 3.0;
 | 
				
			||||||
| 
						 | 
					@ -110,7 +122,8 @@ class BreakLineAlgorithm {
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                var returnCost = Infinity;
 | 
					                var returnCost = Infinity;
 | 
				
			||||||
                for (var k = 0; k < j; k++) {
 | 
					                for (var k = 0; k < j; k++) {
 | 
				
			||||||
                let tmp = this.totalCostAux(items, k, lineWidth) + this.lineCost(items, k + 1, j, lineWidth) ** 3.0;
 | 
					                    let tmp1 = yield Promise.all([this.totalCostAux(items, k, lineWidth), this.lineCost(items, k + 1, j, lineWidth)]);
 | 
				
			||||||
 | 
					                    let tmp = tmp1[0] + tmp1[1] ** 3;
 | 
				
			||||||
                    if (returnCost > tmp) {
 | 
					                    if (returnCost > tmp) {
 | 
				
			||||||
                        this.prevNodes[j] = k;
 | 
					                        this.prevNodes[j] = k;
 | 
				
			||||||
                        returnCost = tmp;
 | 
					                        returnCost = tmp;
 | 
				
			||||||
| 
						 | 
					@ -119,7 +132,7 @@ class BreakLineAlgorithm {
 | 
				
			||||||
                this.totalCostAuxStorage[j] = returnCost;
 | 
					                this.totalCostAuxStorage[j] = returnCost;
 | 
				
			||||||
                return returnCost;
 | 
					                return returnCost;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        return returnCost;
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * check the line cost of a line containing items[i..j]
 | 
					     * check the line cost of a line containing items[i..j]
 | 
				
			||||||
| 
						 | 
					@ -129,6 +142,7 @@ class BreakLineAlgorithm {
 | 
				
			||||||
     * @param lineWidth line width
 | 
					     * @param lineWidth line width
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    lineCost(items, i, j, lineWidth) {
 | 
					    lineCost(items, i, j, lineWidth) {
 | 
				
			||||||
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            if (this.lineCostStorage[i] !== null && this.lineCostStorage[i][j] !== null) {
 | 
					            if (this.lineCostStorage[i] !== null && this.lineCostStorage[i][j] !== null) {
 | 
				
			||||||
                return this.lineCostStorage[i][j];
 | 
					                return this.lineCostStorage[i][j];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -152,6 +166,7 @@ class BreakLineAlgorithm {
 | 
				
			||||||
                    return returnValue;
 | 
					                    return returnValue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.BreakLineAlgorithm = BreakLineAlgorithm;
 | 
					exports.BreakLineAlgorithm = BreakLineAlgorithm;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -150,7 +150,6 @@ export class BreakLineAlgorithm {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return returnCost;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue