Transformed
This commit is contained in:
+31
-30
@@ -1,10 +1,10 @@
|
||||
goog.provide('ol.structs.LRUCache');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.events.EventType');
|
||||
|
||||
/**
|
||||
* @module ol/structs/LRUCache
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_asserts_ from '../asserts.js';
|
||||
import _ol_events_EventTarget_ from '../events/EventTarget.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
|
||||
/**
|
||||
* Implements a Least-Recently-Used cache where the keys do not conflict with
|
||||
@@ -17,9 +17,9 @@ goog.require('ol.events.EventType');
|
||||
* @template T
|
||||
* @param {number=} opt_highWaterMark High water mark.
|
||||
*/
|
||||
ol.structs.LRUCache = function(opt_highWaterMark) {
|
||||
var _ol_structs_LRUCache_ = function(opt_highWaterMark) {
|
||||
|
||||
ol.events.EventTarget.call(this);
|
||||
_ol_events_EventTarget_.call(this);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -52,13 +52,13 @@ ol.structs.LRUCache = function(opt_highWaterMark) {
|
||||
|
||||
};
|
||||
|
||||
ol.inherits(ol.structs.LRUCache, ol.events.EventTarget);
|
||||
_ol_.inherits(_ol_structs_LRUCache_, _ol_events_EventTarget_);
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Can expire cache.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.canExpireCache = function() {
|
||||
_ol_structs_LRUCache_.prototype.canExpireCache = function() {
|
||||
return this.getCount() > this.highWaterMark;
|
||||
};
|
||||
|
||||
@@ -66,12 +66,12 @@ ol.structs.LRUCache.prototype.canExpireCache = function() {
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.clear = function() {
|
||||
_ol_structs_LRUCache_.prototype.clear = function() {
|
||||
this.count_ = 0;
|
||||
this.entries_ = {};
|
||||
this.oldest_ = null;
|
||||
this.newest_ = null;
|
||||
this.dispatchEvent(ol.events.EventType.CLEAR);
|
||||
this.dispatchEvent(_ol_events_EventType_.CLEAR);
|
||||
};
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ ol.structs.LRUCache.prototype.clear = function() {
|
||||
* @param {string} key Key.
|
||||
* @return {boolean} Contains key.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.containsKey = function(key) {
|
||||
_ol_structs_LRUCache_.prototype.containsKey = function(key) {
|
||||
return this.entries_.hasOwnProperty(key);
|
||||
};
|
||||
|
||||
@@ -92,7 +92,7 @@ ol.structs.LRUCache.prototype.containsKey = function(key) {
|
||||
* @param {S=} opt_this The object to use as `this` in `f`.
|
||||
* @template S
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.forEach = function(f, opt_this) {
|
||||
_ol_structs_LRUCache_.prototype.forEach = function(f, opt_this) {
|
||||
var entry = this.oldest_;
|
||||
while (entry) {
|
||||
f.call(opt_this, entry.value_, entry.key_, this);
|
||||
@@ -105,9 +105,9 @@ ol.structs.LRUCache.prototype.forEach = function(f, opt_this) {
|
||||
* @param {string} key Key.
|
||||
* @return {T} Value.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.get = function(key) {
|
||||
_ol_structs_LRUCache_.prototype.get = function(key) {
|
||||
var entry = this.entries_[key];
|
||||
ol.asserts.assert(entry !== undefined,
|
||||
_ol_asserts_.assert(entry !== undefined,
|
||||
15); // Tried to get a value for a key that does not exist in the cache
|
||||
if (entry === this.newest_) {
|
||||
return entry.value_;
|
||||
@@ -131,9 +131,9 @@ ol.structs.LRUCache.prototype.get = function(key) {
|
||||
* @param {string} key The entry key.
|
||||
* @return {T} The removed entry.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.remove = function(key) {
|
||||
_ol_structs_LRUCache_.prototype.remove = function(key) {
|
||||
var entry = this.entries_[key];
|
||||
ol.asserts.assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache
|
||||
_ol_asserts_.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);
|
||||
if (this.newest_) {
|
||||
@@ -157,7 +157,7 @@ ol.structs.LRUCache.prototype.remove = function(key) {
|
||||
/**
|
||||
* @return {number} Count.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.getCount = function() {
|
||||
_ol_structs_LRUCache_.prototype.getCount = function() {
|
||||
return this.count_;
|
||||
};
|
||||
|
||||
@@ -165,7 +165,7 @@ ol.structs.LRUCache.prototype.getCount = function() {
|
||||
/**
|
||||
* @return {Array.<string>} Keys.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.getKeys = function() {
|
||||
_ol_structs_LRUCache_.prototype.getKeys = function() {
|
||||
var keys = new Array(this.count_);
|
||||
var i = 0;
|
||||
var entry;
|
||||
@@ -179,7 +179,7 @@ ol.structs.LRUCache.prototype.getKeys = function() {
|
||||
/**
|
||||
* @return {Array.<T>} Values.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.getValues = function() {
|
||||
_ol_structs_LRUCache_.prototype.getValues = function() {
|
||||
var values = new Array(this.count_);
|
||||
var i = 0;
|
||||
var entry;
|
||||
@@ -193,7 +193,7 @@ ol.structs.LRUCache.prototype.getValues = function() {
|
||||
/**
|
||||
* @return {T} Last value.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.peekLast = function() {
|
||||
_ol_structs_LRUCache_.prototype.peekLast = function() {
|
||||
return this.oldest_.value_;
|
||||
};
|
||||
|
||||
@@ -201,7 +201,7 @@ ol.structs.LRUCache.prototype.peekLast = function() {
|
||||
/**
|
||||
* @return {string} Last key.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.peekLastKey = function() {
|
||||
_ol_structs_LRUCache_.prototype.peekLastKey = function() {
|
||||
return this.oldest_.key_;
|
||||
};
|
||||
|
||||
@@ -210,7 +210,7 @@ ol.structs.LRUCache.prototype.peekLastKey = function() {
|
||||
* Get the key of the newest item in the cache. Throws if the cache is empty.
|
||||
* @return {string} The newest key.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.peekFirstKey = function() {
|
||||
_ol_structs_LRUCache_.prototype.peekFirstKey = function() {
|
||||
return this.newest_.key_;
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ ol.structs.LRUCache.prototype.peekFirstKey = function() {
|
||||
/**
|
||||
* @return {T} value Value.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.pop = function() {
|
||||
_ol_structs_LRUCache_.prototype.pop = function() {
|
||||
var entry = this.oldest_;
|
||||
delete this.entries_[entry.key_];
|
||||
if (entry.newer) {
|
||||
@@ -237,7 +237,7 @@ ol.structs.LRUCache.prototype.pop = function() {
|
||||
* @param {string} key Key.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.replace = function(key, value) {
|
||||
_ol_structs_LRUCache_.prototype.replace = function(key, value) {
|
||||
this.get(key); // update `newest_`
|
||||
this.entries_[key].value_ = value;
|
||||
};
|
||||
@@ -247,8 +247,8 @@ ol.structs.LRUCache.prototype.replace = function(key, value) {
|
||||
* @param {string} key Key.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.set = function(key, value) {
|
||||
ol.asserts.assert(!(key in this.entries_),
|
||||
_ol_structs_LRUCache_.prototype.set = function(key, value) {
|
||||
_ol_asserts_.assert(!(key in this.entries_),
|
||||
16); // Tried to set a value for a key that is used already
|
||||
var entry = /** @type {ol.LRUCacheEntry} */ ({
|
||||
key_: key,
|
||||
@@ -270,8 +270,9 @@ ol.structs.LRUCache.prototype.set = function(key, value) {
|
||||
/**
|
||||
* Prune the cache.
|
||||
*/
|
||||
ol.structs.LRUCache.prototype.prune = function() {
|
||||
_ol_structs_LRUCache_.prototype.prune = function() {
|
||||
while (this.canExpireCache()) {
|
||||
this.pop();
|
||||
}
|
||||
};
|
||||
export default _ol_structs_LRUCache_;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.structs.LinkedList');
|
||||
|
||||
/**
|
||||
* @module ol/structs/LinkedList
|
||||
*/
|
||||
/**
|
||||
* Creates an empty linked list structure.
|
||||
*
|
||||
@@ -8,7 +9,7 @@ goog.provide('ol.structs.LinkedList');
|
||||
* @param {boolean=} opt_circular The last item is connected to the first one,
|
||||
* and the first item to the last one. Default is true.
|
||||
*/
|
||||
ol.structs.LinkedList = function(opt_circular) {
|
||||
var _ol_structs_LinkedList_ = function(opt_circular) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -46,7 +47,7 @@ ol.structs.LinkedList = function(opt_circular) {
|
||||
*
|
||||
* @param {?} data Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.insertItem = function(data) {
|
||||
_ol_structs_LinkedList_.prototype.insertItem = function(data) {
|
||||
|
||||
/** @type {ol.LinkedListItem} */
|
||||
var item = {
|
||||
@@ -87,7 +88,7 @@ ol.structs.LinkedList.prototype.insertItem = function(data) {
|
||||
* Removes the current item from the list. Sets the cursor to the next item,
|
||||
* if possible.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.removeItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.removeItem = function() {
|
||||
var head = this.head_;
|
||||
if (head) {
|
||||
var next = head.next;
|
||||
@@ -118,7 +119,7 @@ ol.structs.LinkedList.prototype.removeItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.firstItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.firstItem = function() {
|
||||
this.head_ = this.first_;
|
||||
if (this.head_) {
|
||||
return this.head_.data;
|
||||
@@ -131,7 +132,7 @@ ol.structs.LinkedList.prototype.firstItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.lastItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.lastItem = function() {
|
||||
this.head_ = this.last_;
|
||||
if (this.head_) {
|
||||
return this.head_.data;
|
||||
@@ -144,7 +145,7 @@ ol.structs.LinkedList.prototype.lastItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.nextItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.nextItem = function() {
|
||||
if (this.head_ && this.head_.next) {
|
||||
this.head_ = this.head_.next;
|
||||
return this.head_.data;
|
||||
@@ -157,7 +158,7 @@ ol.structs.LinkedList.prototype.nextItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.getNextItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.getNextItem = function() {
|
||||
if (this.head_ && this.head_.next) {
|
||||
return this.head_.next.data;
|
||||
}
|
||||
@@ -169,7 +170,7 @@ ol.structs.LinkedList.prototype.getNextItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.prevItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.prevItem = function() {
|
||||
if (this.head_ && this.head_.prev) {
|
||||
this.head_ = this.head_.prev;
|
||||
return this.head_.data;
|
||||
@@ -182,7 +183,7 @@ ol.structs.LinkedList.prototype.prevItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.getPrevItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.getPrevItem = function() {
|
||||
if (this.head_ && this.head_.prev) {
|
||||
return this.head_.prev.data;
|
||||
}
|
||||
@@ -194,7 +195,7 @@ ol.structs.LinkedList.prototype.getPrevItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.getCurrItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.getCurrItem = function() {
|
||||
if (this.head_) {
|
||||
return this.head_.data;
|
||||
}
|
||||
@@ -205,7 +206,7 @@ ol.structs.LinkedList.prototype.getCurrItem = function() {
|
||||
* Sets the first item of the list. This only works for circular lists, and sets
|
||||
* the last item accordingly.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.setFirstItem = function() {
|
||||
_ol_structs_LinkedList_.prototype.setFirstItem = function() {
|
||||
if (this.circular_ && this.head_) {
|
||||
this.first_ = this.head_;
|
||||
this.last_ = this.head_.prev;
|
||||
@@ -216,7 +217,7 @@ ol.structs.LinkedList.prototype.setFirstItem = function() {
|
||||
* Concatenates two lists.
|
||||
* @param {ol.structs.LinkedList} list List to merge into the current list.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.concat = function(list) {
|
||||
_ol_structs_LinkedList_.prototype.concat = function(list) {
|
||||
if (list.head_) {
|
||||
if (this.head_) {
|
||||
var end = this.head_.next;
|
||||
@@ -243,6 +244,7 @@ ol.structs.LinkedList.prototype.concat = function(list) {
|
||||
*
|
||||
* @return {number} Length.
|
||||
*/
|
||||
ol.structs.LinkedList.prototype.getLength = function() {
|
||||
_ol_structs_LinkedList_.prototype.getLength = function() {
|
||||
return this.length_;
|
||||
};
|
||||
export default _ol_structs_LinkedList_;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.provide('ol.structs.PriorityQueue');
|
||||
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.obj');
|
||||
|
||||
/**
|
||||
* @module ol/structs/PriorityQueue
|
||||
*/
|
||||
import _ol_asserts_ from '../asserts.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
|
||||
/**
|
||||
* Priority queue.
|
||||
@@ -19,7 +19,7 @@ goog.require('ol.obj');
|
||||
* @struct
|
||||
* @template T
|
||||
*/
|
||||
ol.structs.PriorityQueue = function(priorityFunction, keyFunction) {
|
||||
var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) {
|
||||
|
||||
/**
|
||||
* @type {function(T): number}
|
||||
@@ -58,16 +58,16 @@ ol.structs.PriorityQueue = function(priorityFunction, keyFunction) {
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.structs.PriorityQueue.DROP = Infinity;
|
||||
_ol_structs_PriorityQueue_.DROP = Infinity;
|
||||
|
||||
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.clear = function() {
|
||||
_ol_structs_PriorityQueue_.prototype.clear = function() {
|
||||
this.elements_.length = 0;
|
||||
this.priorities_.length = 0;
|
||||
ol.obj.clear(this.queuedElements_);
|
||||
_ol_obj_.clear(this.queuedElements_);
|
||||
};
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ ol.structs.PriorityQueue.prototype.clear = function() {
|
||||
* Remove and return the highest-priority element. O(log N).
|
||||
* @return {T} Element.
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.dequeue = function() {
|
||||
_ol_structs_PriorityQueue_.prototype.dequeue = function() {
|
||||
var elements = this.elements_;
|
||||
var priorities = this.priorities_;
|
||||
var element = elements[0];
|
||||
@@ -98,11 +98,11 @@ ol.structs.PriorityQueue.prototype.dequeue = function() {
|
||||
* @param {T} element Element.
|
||||
* @return {boolean} The element was added to the queue.
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.enqueue = function(element) {
|
||||
ol.asserts.assert(!(this.keyFunction_(element) in this.queuedElements_),
|
||||
_ol_structs_PriorityQueue_.prototype.enqueue = function(element) {
|
||||
_ol_asserts_.assert(!(this.keyFunction_(element) in this.queuedElements_),
|
||||
31); // Tried to enqueue an `element` that was already added to the queue
|
||||
var priority = this.priorityFunction_(element);
|
||||
if (priority != ol.structs.PriorityQueue.DROP) {
|
||||
if (priority != _ol_structs_PriorityQueue_.DROP) {
|
||||
this.elements_.push(element);
|
||||
this.priorities_.push(priority);
|
||||
this.queuedElements_[this.keyFunction_(element)] = true;
|
||||
@@ -116,7 +116,7 @@ ol.structs.PriorityQueue.prototype.enqueue = function(element) {
|
||||
/**
|
||||
* @return {number} Count.
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.getCount = function() {
|
||||
_ol_structs_PriorityQueue_.prototype.getCount = function() {
|
||||
return this.elements_.length;
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ ol.structs.PriorityQueue.prototype.getCount = function() {
|
||||
* @return {number} The index of the left child.
|
||||
* @private
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.getLeftChildIndex_ = function(index) {
|
||||
_ol_structs_PriorityQueue_.prototype.getLeftChildIndex_ = function(index) {
|
||||
return index * 2 + 1;
|
||||
};
|
||||
|
||||
@@ -138,7 +138,7 @@ ol.structs.PriorityQueue.prototype.getLeftChildIndex_ = function(index) {
|
||||
* @return {number} The index of the right child.
|
||||
* @private
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.getRightChildIndex_ = function(index) {
|
||||
_ol_structs_PriorityQueue_.prototype.getRightChildIndex_ = function(index) {
|
||||
return index * 2 + 2;
|
||||
};
|
||||
|
||||
@@ -149,7 +149,7 @@ ol.structs.PriorityQueue.prototype.getRightChildIndex_ = function(index) {
|
||||
* @return {number} The index of the parent.
|
||||
* @private
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.getParentIndex_ = function(index) {
|
||||
_ol_structs_PriorityQueue_.prototype.getParentIndex_ = function(index) {
|
||||
return (index - 1) >> 1;
|
||||
};
|
||||
|
||||
@@ -158,7 +158,7 @@ ol.structs.PriorityQueue.prototype.getParentIndex_ = function(index) {
|
||||
* Make this a heap. O(N).
|
||||
* @private
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.heapify_ = function() {
|
||||
_ol_structs_PriorityQueue_.prototype.heapify_ = function() {
|
||||
var i;
|
||||
for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) {
|
||||
this.siftUp_(i);
|
||||
@@ -169,7 +169,7 @@ ol.structs.PriorityQueue.prototype.heapify_ = function() {
|
||||
/**
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.isEmpty = function() {
|
||||
_ol_structs_PriorityQueue_.prototype.isEmpty = function() {
|
||||
return this.elements_.length === 0;
|
||||
};
|
||||
|
||||
@@ -178,7 +178,7 @@ ol.structs.PriorityQueue.prototype.isEmpty = function() {
|
||||
* @param {string} key Key.
|
||||
* @return {boolean} Is key queued.
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.isKeyQueued = function(key) {
|
||||
_ol_structs_PriorityQueue_.prototype.isKeyQueued = function(key) {
|
||||
return key in this.queuedElements_;
|
||||
};
|
||||
|
||||
@@ -187,7 +187,7 @@ ol.structs.PriorityQueue.prototype.isKeyQueued = function(key) {
|
||||
* @param {T} element Element.
|
||||
* @return {boolean} Is queued.
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.isQueued = function(element) {
|
||||
_ol_structs_PriorityQueue_.prototype.isQueued = function(element) {
|
||||
return this.isKeyQueued(this.keyFunction_(element));
|
||||
};
|
||||
|
||||
@@ -196,7 +196,7 @@ ol.structs.PriorityQueue.prototype.isQueued = function(element) {
|
||||
* @param {number} index The index of the node to move down.
|
||||
* @private
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.siftUp_ = function(index) {
|
||||
_ol_structs_PriorityQueue_.prototype.siftUp_ = function(index) {
|
||||
var elements = this.elements_;
|
||||
var priorities = this.priorities_;
|
||||
var count = elements.length;
|
||||
@@ -228,7 +228,7 @@ ol.structs.PriorityQueue.prototype.siftUp_ = function(index) {
|
||||
* @param {number} index The index of the node to move up.
|
||||
* @private
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.siftDown_ = function(startIndex, index) {
|
||||
_ol_structs_PriorityQueue_.prototype.siftDown_ = function(startIndex, index) {
|
||||
var elements = this.elements_;
|
||||
var priorities = this.priorities_;
|
||||
var element = elements[index];
|
||||
@@ -252,7 +252,7 @@ ol.structs.PriorityQueue.prototype.siftDown_ = function(startIndex, index) {
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
ol.structs.PriorityQueue.prototype.reprioritize = function() {
|
||||
_ol_structs_PriorityQueue_.prototype.reprioritize = function() {
|
||||
var priorityFunction = this.priorityFunction_;
|
||||
var elements = this.elements_;
|
||||
var priorities = this.priorities_;
|
||||
@@ -262,7 +262,7 @@ ol.structs.PriorityQueue.prototype.reprioritize = function() {
|
||||
for (i = 0; i < n; ++i) {
|
||||
element = elements[i];
|
||||
priority = priorityFunction(element);
|
||||
if (priority == ol.structs.PriorityQueue.DROP) {
|
||||
if (priority == _ol_structs_PriorityQueue_.DROP) {
|
||||
delete this.queuedElements_[this.keyFunction_(element)];
|
||||
} else {
|
||||
priorities[index] = priority;
|
||||
@@ -273,3 +273,4 @@ ol.structs.PriorityQueue.prototype.reprioritize = function() {
|
||||
priorities.length = index;
|
||||
this.heapify_();
|
||||
};
|
||||
export default _ol_structs_PriorityQueue_;
|
||||
|
||||
+30
-29
@@ -1,10 +1,10 @@
|
||||
goog.provide('ol.structs.RBush');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.ext.rbush');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.obj');
|
||||
|
||||
/**
|
||||
* @module ol/structs/RBush
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_ext_rbush_ from 'rbush';
|
||||
import _ol_extent_ from '../extent.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
|
||||
/**
|
||||
* Wrapper around the RBush by Vladimir Agafonkin.
|
||||
@@ -15,12 +15,12 @@ goog.require('ol.obj');
|
||||
* @struct
|
||||
* @template T
|
||||
*/
|
||||
ol.structs.RBush = function(opt_maxEntries) {
|
||||
var _ol_structs_RBush_ = function(opt_maxEntries) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this.rbush_ = ol.ext.rbush(opt_maxEntries);
|
||||
this.rbush_ = _ol_ext_rbush_(opt_maxEntries);
|
||||
|
||||
/**
|
||||
* A mapping between the objects added to this rbush wrapper
|
||||
@@ -38,7 +38,7 @@ ol.structs.RBush = function(opt_maxEntries) {
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
ol.structs.RBush.prototype.insert = function(extent, value) {
|
||||
_ol_structs_RBush_.prototype.insert = function(extent, value) {
|
||||
/** @type {ol.RBushEntry} */
|
||||
var item = {
|
||||
minX: extent[0],
|
||||
@@ -49,7 +49,7 @@ ol.structs.RBush.prototype.insert = function(extent, value) {
|
||||
};
|
||||
|
||||
this.rbush_.insert(item);
|
||||
this.items_[ol.getUid(value)] = item;
|
||||
this.items_[_ol_.getUid(value)] = item;
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ ol.structs.RBush.prototype.insert = function(extent, value) {
|
||||
* @param {Array.<ol.Extent>} extents Extents.
|
||||
* @param {Array.<T>} values Values.
|
||||
*/
|
||||
ol.structs.RBush.prototype.load = function(extents, values) {
|
||||
_ol_structs_RBush_.prototype.load = function(extents, values) {
|
||||
var items = new Array(values.length);
|
||||
for (var i = 0, l = values.length; i < l; i++) {
|
||||
var extent = extents[i];
|
||||
@@ -73,7 +73,7 @@ ol.structs.RBush.prototype.load = function(extents, values) {
|
||||
value: value
|
||||
};
|
||||
items[i] = item;
|
||||
this.items_[ol.getUid(value)] = item;
|
||||
this.items_[_ol_.getUid(value)] = item;
|
||||
}
|
||||
this.rbush_.load(items);
|
||||
};
|
||||
@@ -84,8 +84,8 @@ ol.structs.RBush.prototype.load = function(extents, values) {
|
||||
* @param {T} value Value.
|
||||
* @return {boolean} Removed.
|
||||
*/
|
||||
ol.structs.RBush.prototype.remove = function(value) {
|
||||
var uid = ol.getUid(value);
|
||||
_ol_structs_RBush_.prototype.remove = function(value) {
|
||||
var uid = _ol_.getUid(value);
|
||||
|
||||
// get the object in which the value was wrapped when adding to the
|
||||
// internal rbush. then use that object to do the removal.
|
||||
@@ -100,10 +100,10 @@ ol.structs.RBush.prototype.remove = function(value) {
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
ol.structs.RBush.prototype.update = function(extent, value) {
|
||||
var item = this.items_[ol.getUid(value)];
|
||||
_ol_structs_RBush_.prototype.update = function(extent, value) {
|
||||
var item = this.items_[_ol_.getUid(value)];
|
||||
var bbox = [item.minX, item.minY, item.maxX, item.maxY];
|
||||
if (!ol.extent.equals(bbox, extent)) {
|
||||
if (!_ol_extent_.equals(bbox, extent)) {
|
||||
this.remove(value);
|
||||
this.insert(extent, value);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ ol.structs.RBush.prototype.update = function(extent, value) {
|
||||
* Return all values in the RBush.
|
||||
* @return {Array.<T>} All.
|
||||
*/
|
||||
ol.structs.RBush.prototype.getAll = function() {
|
||||
_ol_structs_RBush_.prototype.getAll = function() {
|
||||
var items = this.rbush_.all();
|
||||
return items.map(function(item) {
|
||||
return item.value;
|
||||
@@ -127,7 +127,7 @@ ol.structs.RBush.prototype.getAll = function() {
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {Array.<T>} All in extent.
|
||||
*/
|
||||
ol.structs.RBush.prototype.getInExtent = function(extent) {
|
||||
_ol_structs_RBush_.prototype.getInExtent = function(extent) {
|
||||
/** @type {ol.RBushEntry} */
|
||||
var bbox = {
|
||||
minX: extent[0],
|
||||
@@ -151,7 +151,7 @@ ol.structs.RBush.prototype.getInExtent = function(extent) {
|
||||
* @return {*} Callback return value.
|
||||
* @template S
|
||||
*/
|
||||
ol.structs.RBush.prototype.forEach = function(callback, opt_this) {
|
||||
_ol_structs_RBush_.prototype.forEach = function(callback, opt_this) {
|
||||
return this.forEach_(this.getAll(), callback, opt_this);
|
||||
};
|
||||
|
||||
@@ -164,7 +164,7 @@ ol.structs.RBush.prototype.forEach = function(callback, opt_this) {
|
||||
* @return {*} Callback return value.
|
||||
* @template S
|
||||
*/
|
||||
ol.structs.RBush.prototype.forEachInExtent = function(extent, callback, opt_this) {
|
||||
_ol_structs_RBush_.prototype.forEachInExtent = function(extent, callback, opt_this) {
|
||||
return this.forEach_(this.getInExtent(extent), callback, opt_this);
|
||||
};
|
||||
|
||||
@@ -177,7 +177,7 @@ ol.structs.RBush.prototype.forEachInExtent = function(extent, callback, opt_this
|
||||
* @return {*} Callback return value.
|
||||
* @template S
|
||||
*/
|
||||
ol.structs.RBush.prototype.forEach_ = function(values, callback, opt_this) {
|
||||
_ol_structs_RBush_.prototype.forEach_ = function(values, callback, opt_this) {
|
||||
var result;
|
||||
for (var i = 0, l = values.length; i < l; i++) {
|
||||
result = callback.call(opt_this, values[i]);
|
||||
@@ -192,15 +192,15 @@ ol.structs.RBush.prototype.forEach_ = function(values, callback, opt_this) {
|
||||
/**
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.structs.RBush.prototype.isEmpty = function() {
|
||||
return ol.obj.isEmpty(this.items_);
|
||||
_ol_structs_RBush_.prototype.isEmpty = function() {
|
||||
return _ol_obj_.isEmpty(this.items_);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Remove all values from the RBush.
|
||||
*/
|
||||
ol.structs.RBush.prototype.clear = function() {
|
||||
_ol_structs_RBush_.prototype.clear = function() {
|
||||
this.rbush_.clear();
|
||||
this.items_ = {};
|
||||
};
|
||||
@@ -210,19 +210,20 @@ ol.structs.RBush.prototype.clear = function() {
|
||||
* @param {ol.Extent=} opt_extent Extent.
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.structs.RBush.prototype.getExtent = function(opt_extent) {
|
||||
_ol_structs_RBush_.prototype.getExtent = function(opt_extent) {
|
||||
// FIXME add getExtent() to rbush
|
||||
var data = this.rbush_.data;
|
||||
return ol.extent.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
|
||||
return _ol_extent_.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.structs.RBush} rbush R-Tree.
|
||||
*/
|
||||
ol.structs.RBush.prototype.concat = function(rbush) {
|
||||
_ol_structs_RBush_.prototype.concat = function(rbush) {
|
||||
this.rbush_.load(rbush.rbush_.all());
|
||||
for (var i in rbush.items_) {
|
||||
this.items_[i | 0] = rbush.items_[i | 0];
|
||||
}
|
||||
};
|
||||
export default _ol_structs_RBush_;
|
||||
|
||||
Reference in New Issue
Block a user