From 11da20e744dc24c324bb0ca5213b830ee1e7d97f Mon Sep 17 00:00:00 2001 From: Michael Kuenzli Date: Wed, 18 Apr 2018 16:09:17 +0200 Subject: [PATCH 1/3] Move ol.LinkedListItem to ol/structs/LinkedList --- src/ol/structs/LinkedList.js | 17 +++++++++++++---- src/ol/typedefs.js | 8 -------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ol/structs/LinkedList.js b/src/ol/structs/LinkedList.js index 389df5d059..e67e2d9a1a 100644 --- a/src/ol/structs/LinkedList.js +++ b/src/ol/structs/LinkedList.js @@ -2,6 +2,15 @@ * @module ol/structs/LinkedList */ + +/** + * @typedef {Object} Item + * @property {module:ol/structs/LinkedList~Item} [prev] + * @property {module:ol/structs/LinkedList~Item} [next] + * @property {?} data + */ + + /** * Creates an empty linked list structure. * @@ -14,19 +23,19 @@ const LinkedList = function(opt_circular) { /** * @private - * @type {ol.LinkedListItem|undefined} + * @type {module:ol/structs/LinkedList~Item}|undefined} */ this.first_ = undefined; /** * @private - * @type {ol.LinkedListItem|undefined} + * @type {module:ol/structs/LinkedList~Item}|undefined} */ this.last_ = undefined; /** * @private - * @type {ol.LinkedListItem|undefined} + * @type {module:ol/structs/LinkedList~Item}|undefined} */ this.head_ = undefined; @@ -50,7 +59,7 @@ const LinkedList = function(opt_circular) { */ LinkedList.prototype.insertItem = function(data) { - /** @type {ol.LinkedListItem} */ + /** @type {module:ol/structs/LinkedList~Item}} */ const item = { prev: undefined, next: undefined, diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index a1500d291e..7bac31ea30 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -120,14 +120,6 @@ ol.CanvasTextState; ol.DeclutterGroup; -/** - * @typedef {{prev: (ol.LinkedListItem|undefined), - * next: (ol.LinkedListItem|undefined), - * data: ?}} - */ -ol.LinkedListItem; - - /** * A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and * returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this From b76492c3b8082f5597538b35b12398fd0b0460f1 Mon Sep 17 00:00:00 2001 From: Michael Kuenzli Date: Wed, 18 Apr 2018 16:14:03 +0200 Subject: [PATCH 2/3] Move ol.LRUCacheEntry to ol/structs/LRUCache --- src/ol/structs/LRUCache.js | 26 ++++++++++++++++++-------- src/ol/typedefs.js | 9 --------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/ol/structs/LRUCache.js b/src/ol/structs/LRUCache.js index 944fc71994..9e29f3a4cc 100644 --- a/src/ol/structs/LRUCache.js +++ b/src/ol/structs/LRUCache.js @@ -6,6 +6,16 @@ import {assert} from '../asserts.js'; import EventTarget from '../events/EventTarget.js'; import EventType from '../events/EventType.js'; + +/** + * @typedef {Object} Entry + * @property {string} key_ + * @property {Object} newer + * @property {Object} older + * @property {value_} value_ + */ + + /** * Implements a Least-Recently-Used cache where the keys do not conflict with * Object's properties (e.g. 'hasOwnProperty' is not allowed as a key). Expiring @@ -34,19 +44,19 @@ const LRUCache = function(opt_highWaterMark) { /** * @private - * @type {!Object.} + * @type {!Object.} */ this.entries_ = {}; /** * @private - * @type {?ol.LRUCacheEntry} + * @type {?module:ol/structs/LRUCache~Entry} */ this.oldest_ = null; /** * @private - * @type {?ol.LRUCacheEntry} + * @type {?module:ol/structs/LRUCache~Entry} */ this.newest_ = null; @@ -112,7 +122,7 @@ LRUCache.prototype.get = function(key) { if (entry === this.newest_) { return entry.value_; } else if (entry === this.oldest_) { - this.oldest_ = /** @type {ol.LRUCacheEntry} */ (this.oldest_.newer); + this.oldest_ = /** @type {module:ol/structs/LRUCache~Entry} */ (this.oldest_.newer); this.oldest_.older = null; } else { entry.newer.older = entry.older; @@ -135,12 +145,12 @@ LRUCache.prototype.remove = function(key) { const entry = this.entries_[key]; assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache if (entry === this.newest_) { - this.newest_ = /** @type {ol.LRUCacheEntry} */ (entry.older); + this.newest_ = /** @type {module:ol/structs/LRUCache~Entry} */ (entry.older); if (this.newest_) { this.newest_.newer = null; } } else if (entry === this.oldest_) { - this.oldest_ = /** @type {ol.LRUCacheEntry} */ (entry.newer); + this.oldest_ = /** @type {module:ol/structs/LRUCache~Entry} */ (entry.newer); if (this.oldest_) { this.oldest_.older = null; } @@ -224,7 +234,7 @@ LRUCache.prototype.pop = function() { if (entry.newer) { entry.newer.older = null; } - this.oldest_ = /** @type {ol.LRUCacheEntry} */ (entry.newer); + this.oldest_ = /** @type {module:ol/structs/LRUCache~Entry} */ (entry.newer); if (!this.oldest_) { this.newest_ = null; } @@ -250,7 +260,7 @@ LRUCache.prototype.replace = function(key, value) { LRUCache.prototype.set = function(key, value) { assert(!(key in this.entries_), 16); // Tried to set a value for a key that is used already - const entry = /** @type {ol.LRUCacheEntry} */ ({ + const entry = /** @type {module:ol/structs/LRUCache~Entry} */ ({ key_: key, newer: null, older: this.newest_, diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 7bac31ea30..5b47c28b5e 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -130,15 +130,6 @@ ol.DeclutterGroup; ol.LoadingStrategy; -/** - * @typedef {{key_: string, - * newer: Object, - * older: Object, - * value_: *}} - */ -ol.LRUCacheEntry; - - /** * A function that takes an array of input data, performs some operation, and * returns an array of output data. From 44fb48d63fe46cf4fad27b0281f819eaede49d74 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 18 Apr 2018 16:19:06 -0600 Subject: [PATCH 3/3] Type is * instead of value_ --- src/ol/structs/LRUCache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/structs/LRUCache.js b/src/ol/structs/LRUCache.js index 9e29f3a4cc..a601a9a005 100644 --- a/src/ol/structs/LRUCache.js +++ b/src/ol/structs/LRUCache.js @@ -12,7 +12,7 @@ import EventType from '../events/EventType.js'; * @property {string} key_ * @property {Object} newer * @property {Object} older - * @property {value_} value_ + * @property {*} value_ */