From 4b427b1525aee186568b1d9589b051c1904ac8d0 Mon Sep 17 00:00:00 2001 From: Joshua Horowitz Date: Mon, 17 Sep 2018 14:55:43 -0400 Subject: [PATCH] Removed 'compare' functions and other unnecessary bits --- lib/kiwi.js | 46 +++++++++++++--------------------------------- src/constraint.ts | 10 +--------- src/expression.ts | 4 ++-- src/maptype.ts | 2 +- src/solver.ts | 17 +++++------------ src/strength.ts | 10 +++++----- src/variable.ts | 8 -------- 7 files changed, 27 insertions(+), 70 deletions(-) diff --git a/lib/kiwi.js b/lib/kiwi.js index 3a89501..cac86c7 100644 --- a/lib/kiwi.js +++ b/lib/kiwi.js @@ -58,7 +58,7 @@ | | The full license is in the file COPYING.txt, distributed with this software. |----------------------------------------------------------------------------*/ - function createMap(compare) { + function createMap() { return new IndexedMap(); } var IndexedMap = /** @class */ (function () { @@ -221,13 +221,6 @@ this._id = VarId++; this._name = name; } - /** - * A static variable comparison function. - * @private - */ - Variable.Compare = function (a, b) { - return a.id() - b.id(); - }; /** * Returns the unique id number of the variable. * @private @@ -439,7 +432,7 @@ return this._terms.size() == 0; }; Expression.prototype.toString = function () { - var result = this._terms.array.map(function (pair, idx) { + var result = this._terms.array.map(function (pair) { return (pair.second + "*" + pair.first.toString()); }).join(" + "); if (!this.isConstant() && this._constant !== 0) { @@ -457,7 +450,7 @@ function parseArgs(args) { var constant = 0.0; var factory = function () { return 0.0; }; - var terms = createMap(Variable.Compare); + var terms = createMap(); for (var i = 0, n = args.length; i < n; ++i) { var item = args[i]; if (typeof item === "number") { @@ -521,11 +514,11 @@ /** * Create a new symbolic strength. * - * @param {Number} a strong - * @param {Number} b medium - * @param {Number} c weak - * @param {Number} [w] weight - * @return {Number} strength + * @param a strong + * @param b medium + * @param c weak + * @param [w] weight + * @return strength */ Strength.create = function (a, b, c, w) { if (w === void 0) { w = 1.0; } @@ -598,13 +591,6 @@ this._expression = expression.minus(rhs); } } - /** - * A static constraint comparison function. - * @private - */ - Constraint.Compare = function (a, b) { - return a.id() - b.id(); - }; /** * Returns the unique id number of the constraint. * @private @@ -1351,28 +1337,28 @@ * @private */ function createCnMap() { - return createMap(Constraint.Compare); + return createMap(); } /** * An internal function for creating a row map. * @private */ function createRowMap() { - return createMap(Symbol.Compare); + return createMap(); } /** * An internal function for creating a variable map. * @private */ function createVarMap() { - return createMap(Variable.Compare); + return createMap(); } /** * An internal function for creating an edit map. * @private */ function createEditMap() { - return createMap(Variable.Compare); + return createMap(); } /** * An enum defining the available symbol types. @@ -1401,12 +1387,6 @@ this._id = id; this._type = type; } - /** - * The static Symbol comparison function. - */ - Symbol.Compare = function (a, b) { - return a.id() - b.id(); - }; /** * Returns the unique id number of the symbol. */ @@ -1436,7 +1416,7 @@ */ function Row(constant) { if (constant === void 0) { constant = 0.0; } - this._cellMap = createMap(Symbol.Compare); + this._cellMap = createMap(); this._constant = constant; } /** diff --git a/src/constraint.ts b/src/constraint.ts index 006f05f..265725e 100644 --- a/src/constraint.ts +++ b/src/constraint.ts @@ -56,14 +56,6 @@ class Constraint { } } - /** - * A static constraint comparison function. - * @private - */ - public static Compare( a: Constraint, b: Constraint ): number { - return a.id() - b.id(); - } - /** * Returns the unique id number of the constraint. * @private @@ -113,4 +105,4 @@ class Constraint { * The internal constraint id counter. * @private */ -let CnId = 0; \ No newline at end of file +let CnId = 0; diff --git a/src/expression.ts b/src/expression.ts index e5dcb60..a9fb118 100644 --- a/src/expression.ts +++ b/src/expression.ts @@ -113,7 +113,7 @@ class Expression { } public toString(): string { - let result = this._terms.array.map(function(pair, idx) { + let result = this._terms.array.map(function(pair) { return (pair.second + "*" + pair.first.toString()); }).join(" + "); @@ -145,7 +145,7 @@ interface IParseResult { function parseArgs( args: IArguments ): IParseResult { let constant = 0.0; let factory = () => 0.0; - let terms = createMap( Variable.Compare ); + let terms = createMap(); for ( let i = 0, n = args.length; i < n; ++i ) { let item = args[ i ]; if ( typeof item === "number" ) { diff --git a/src/maptype.ts b/src/maptype.ts index a14b4f7..8d57688 100644 --- a/src/maptype.ts +++ b/src/maptype.ts @@ -9,7 +9,7 @@ export interface IMap extends IndexedMap { } export -function createMap( compare: any ): IMap { +function createMap(): IMap { return new IndexedMap(); } diff --git a/src/solver.ts b/src/solver.ts index f9f58b0..ed063f0 100644 --- a/src/solver.ts +++ b/src/solver.ts @@ -773,7 +773,7 @@ interface IRowCreation { * @private */ function createCnMap(): IMap { - return createMap( Constraint.Compare ); + return createMap(); } /** @@ -781,7 +781,7 @@ function createCnMap(): IMap { * @private */ function createRowMap(): IMap { - return createMap( Symbol.Compare ); + return createMap(); } /** @@ -789,7 +789,7 @@ function createRowMap(): IMap { * @private */ function createVarMap(): IMap { - return createMap( Variable.Compare ); + return createMap(); } /** @@ -797,7 +797,7 @@ function createVarMap(): IMap { * @private */ function createEditMap(): IMap { - return createMap( Variable.Compare ); + return createMap(); } /** @@ -817,13 +817,6 @@ enum SymbolType { * @private */ class Symbol { - /** - * The static Symbol comparison function. - */ - public static Compare( a: Symbol, b: Symbol ): number { - return a.id() - b.id(); - } - /** * Construct a new Symbol * @@ -1037,6 +1030,6 @@ class Row { } } - private _cellMap = createMap( Symbol.Compare ); + private _cellMap = createMap(); private _constant: number; } diff --git a/src/strength.ts b/src/strength.ts index 1314924..695aad7 100644 --- a/src/strength.ts +++ b/src/strength.ts @@ -13,11 +13,11 @@ /** * Create a new symbolic strength. * - * @param {Number} a strong - * @param {Number} b medium - * @param {Number} c weak - * @param {Number} [w] weight - * @return {Number} strength + * @param a strong + * @param b medium + * @param c weak + * @param [w] weight + * @return strength */ static create( a: number, b: number, c: number, w: number = 1.0 ) { let result: number = 0.0; diff --git a/src/variable.ts b/src/variable.ts index bc32fb0..86edfd4 100644 --- a/src/variable.ts +++ b/src/variable.ts @@ -20,14 +20,6 @@ class Variable { this._name = name; } - /** - * A static variable comparison function. - * @private - */ - public static Compare( a: Variable, b: Variable ): number { - return a.id() - b.id(); - } - /** * Returns the unique id number of the variable. * @private