Merge pull request #8083 from pfirpfel/move-structs-typedefs-to-ol/structs

Move structs typedefs to ol/structs/*
This commit is contained in:
Tim Schaub
2018-04-18 16:27:12 -06:00
committed by GitHub
3 changed files with 31 additions and 29 deletions

View File

@@ -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_
*/
/**
* 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.<string, ol.LRUCacheEntry>}
* @type {!Object.<string, module:ol/structs/LRUCache~Entry>}
*/
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_,

View File

@@ -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,

View File

@@ -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
@@ -138,15 +130,6 @@ ol.LinkedListItem;
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.