UNPKG

openfl

Version:

A fast, productive library for 2D cross-platform development.

63 lines (46 loc) 1.74 kB
// Class: openfl.text._internal.CacheMeasurement var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../../hxClasses_stub").default; var $hxEnums = require("./../../../hxEnums_stub").default; var $import = require("./../../../import_stub").default; function haxe_ds_IntMap() {return require("./../../../haxe/ds/IntMap");} // Constructor var CacheMeasurement = function(wordKey,positions) { this.__collisions = []; this.__wordMap = new (haxe_ds_IntMap().default)(); this.set(wordKey,positions); } // Meta CacheMeasurement.__name__ = "openfl.text._internal.CacheMeasurement"; CacheMeasurement.__isInterface__ = false; CacheMeasurement.prototype = { set: function(wordKey,positions) { this.__addCollision(wordKey,positions); }, get: function(wordKey) { if(this.__collisions.length > 1) { return this.__wordMap.get(this.__collisions.indexOf(wordKey)); } return this.__wordMap.get(0); }, __addCollision: function(wordKey,positions) { if(!this.exists(wordKey)) { this.__wordMap.set(this.__collisions.push(wordKey) - 1,positions); } }, exists: function(wordKey) { if(this.__collisions.length == 0) { return false; } return this.__collisions.indexOf(wordKey) > -1; } }; CacheMeasurement.prototype.__class__ = CacheMeasurement.prototype.constructor = $hxClasses["openfl.text._internal.CacheMeasurement"] = CacheMeasurement; // Init // Statics CacheMeasurement.__meta__ = { obj : { SuppressWarnings : ["checkstyle:FieldDocComment"]}} // Export exports.default = CacheMeasurement;