@@ -17,7 +17,7 @@ import EventType from '../events/EventType.js';
|
||||
* @template T
|
||||
* @param {number=} opt_highWaterMark High water mark.
|
||||
*/
|
||||
var _ol_structs_LRUCache_ = function(opt_highWaterMark) {
|
||||
var LRUCache = function(opt_highWaterMark) {
|
||||
|
||||
EventTarget.call(this);
|
||||
|
||||
@@ -52,13 +52,13 @@ var _ol_structs_LRUCache_ = function(opt_highWaterMark) {
|
||||
|
||||
};
|
||||
|
||||
inherits(_ol_structs_LRUCache_, EventTarget);
|
||||
inherits(LRUCache, EventTarget);
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Can expire cache.
|
||||
*/
|
||||
_ol_structs_LRUCache_.prototype.canExpireCache = function() {
|
||||
LRUCache.prototype.canExpireCache = function() {
|
||||
return this.getCount() > this.highWaterMark;
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ _ol_structs_LRUCache_.prototype.canExpireCache = function() {
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
_ol_structs_LRUCache_.prototype.clear = function() {
|
||||
LRUCache.prototype.clear = function() {
|
||||
this.count_ = 0;
|
||||
this.entries_ = {};
|
||||
this.oldest_ = null;
|
||||
@@ -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) {
|
||||
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) {
|
||||
LRUCache.prototype.forEach = function(f, opt_this) {
|
||||
var entry = this.oldest_;
|
||||
while (entry) {
|
||||
f.call(opt_this, entry.value_, entry.key_, this);
|
||||
@@ -105,7 +105,7 @@ _ol_structs_LRUCache_.prototype.forEach = function(f, opt_this) {
|
||||
* @param {string} key Key.
|
||||
* @return {T} Value.
|
||||
*/
|
||||
_ol_structs_LRUCache_.prototype.get = function(key) {
|
||||
LRUCache.prototype.get = 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
|
||||
@@ -131,7 +131,7 @@ _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) {
|
||||
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
|
||||
if (entry === this.newest_) {
|
||||
@@ -157,7 +157,7 @@ _ol_structs_LRUCache_.prototype.remove = function(key) {
|
||||
/**
|
||||
* @return {number} Count.
|
||||
*/
|
||||
_ol_structs_LRUCache_.prototype.getCount = function() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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) {
|
||||
LRUCache.prototype.replace = function(key, value) {
|
||||
this.get(key); // update `newest_`
|
||||
this.entries_[key].value_ = value;
|
||||
};
|
||||
@@ -247,7 +247,7 @@ _ol_structs_LRUCache_.prototype.replace = function(key, value) {
|
||||
* @param {string} key Key.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
_ol_structs_LRUCache_.prototype.set = function(key, value) {
|
||||
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} */ ({
|
||||
@@ -270,9 +270,9 @@ _ol_structs_LRUCache_.prototype.set = function(key, value) {
|
||||
/**
|
||||
* Prune the cache.
|
||||
*/
|
||||
_ol_structs_LRUCache_.prototype.prune = function() {
|
||||
LRUCache.prototype.prune = function() {
|
||||
while (this.canExpireCache()) {
|
||||
this.pop();
|
||||
}
|
||||
};
|
||||
export default _ol_structs_LRUCache_;
|
||||
export default LRUCache;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @module ol/structs/LinkedList
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates an empty linked list structure.
|
||||
*
|
||||
@@ -9,7 +10,7 @@
|
||||
* @param {boolean=} opt_circular The last item is connected to the first one,
|
||||
* and the first item to the last one. Default is true.
|
||||
*/
|
||||
var _ol_structs_LinkedList_ = function(opt_circular) {
|
||||
var LinkedList = function(opt_circular) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -47,7 +48,7 @@ var _ol_structs_LinkedList_ = function(opt_circular) {
|
||||
*
|
||||
* @param {?} data Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.insertItem = function(data) {
|
||||
LinkedList.prototype.insertItem = function(data) {
|
||||
|
||||
/** @type {ol.LinkedListItem} */
|
||||
var item = {
|
||||
@@ -88,7 +89,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() {
|
||||
LinkedList.prototype.removeItem = function() {
|
||||
var head = this.head_;
|
||||
if (head) {
|
||||
var next = head.next;
|
||||
@@ -119,7 +120,7 @@ _ol_structs_LinkedList_.prototype.removeItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.firstItem = function() {
|
||||
LinkedList.prototype.firstItem = function() {
|
||||
this.head_ = this.first_;
|
||||
if (this.head_) {
|
||||
return this.head_.data;
|
||||
@@ -132,7 +133,7 @@ _ol_structs_LinkedList_.prototype.firstItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.lastItem = function() {
|
||||
LinkedList.prototype.lastItem = function() {
|
||||
this.head_ = this.last_;
|
||||
if (this.head_) {
|
||||
return this.head_.data;
|
||||
@@ -145,7 +146,7 @@ _ol_structs_LinkedList_.prototype.lastItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.nextItem = function() {
|
||||
LinkedList.prototype.nextItem = function() {
|
||||
if (this.head_ && this.head_.next) {
|
||||
this.head_ = this.head_.next;
|
||||
return this.head_.data;
|
||||
@@ -158,7 +159,7 @@ _ol_structs_LinkedList_.prototype.nextItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.getNextItem = function() {
|
||||
LinkedList.prototype.getNextItem = function() {
|
||||
if (this.head_ && this.head_.next) {
|
||||
return this.head_.next.data;
|
||||
}
|
||||
@@ -170,7 +171,7 @@ _ol_structs_LinkedList_.prototype.getNextItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.prevItem = function() {
|
||||
LinkedList.prototype.prevItem = function() {
|
||||
if (this.head_ && this.head_.prev) {
|
||||
this.head_ = this.head_.prev;
|
||||
return this.head_.data;
|
||||
@@ -183,7 +184,7 @@ _ol_structs_LinkedList_.prototype.prevItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.getPrevItem = function() {
|
||||
LinkedList.prototype.getPrevItem = function() {
|
||||
if (this.head_ && this.head_.prev) {
|
||||
return this.head_.prev.data;
|
||||
}
|
||||
@@ -195,7 +196,7 @@ _ol_structs_LinkedList_.prototype.getPrevItem = function() {
|
||||
*
|
||||
* @return {?} Item data.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.getCurrItem = function() {
|
||||
LinkedList.prototype.getCurrItem = function() {
|
||||
if (this.head_) {
|
||||
return this.head_.data;
|
||||
}
|
||||
@@ -206,7 +207,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() {
|
||||
LinkedList.prototype.setFirstItem = function() {
|
||||
if (this.circular_ && this.head_) {
|
||||
this.first_ = this.head_;
|
||||
this.last_ = this.head_.prev;
|
||||
@@ -217,7 +218,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) {
|
||||
LinkedList.prototype.concat = function(list) {
|
||||
if (list.head_) {
|
||||
if (this.head_) {
|
||||
var end = this.head_.next;
|
||||
@@ -244,7 +245,7 @@ _ol_structs_LinkedList_.prototype.concat = function(list) {
|
||||
*
|
||||
* @return {number} Length.
|
||||
*/
|
||||
_ol_structs_LinkedList_.prototype.getLength = function() {
|
||||
LinkedList.prototype.getLength = function() {
|
||||
return this.length_;
|
||||
};
|
||||
export default _ol_structs_LinkedList_;
|
||||
export default LinkedList;
|
||||
|
||||
@@ -19,7 +19,7 @@ import _ol_obj_ from '../obj.js';
|
||||
* @struct
|
||||
* @template T
|
||||
*/
|
||||
var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) {
|
||||
var PriorityQueue = function(priorityFunction, keyFunction) {
|
||||
|
||||
/**
|
||||
* @type {function(T): number}
|
||||
@@ -58,13 +58,13 @@ var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) {
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_structs_PriorityQueue_.DROP = Infinity;
|
||||
PriorityQueue.DROP = Infinity;
|
||||
|
||||
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
_ol_structs_PriorityQueue_.prototype.clear = function() {
|
||||
PriorityQueue.prototype.clear = function() {
|
||||
this.elements_.length = 0;
|
||||
this.priorities_.length = 0;
|
||||
_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() {
|
||||
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) {
|
||||
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 != 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() {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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() {
|
||||
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() {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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() {
|
||||
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 == PriorityQueue.DROP) {
|
||||
delete this.queuedElements_[this.keyFunction_(element)];
|
||||
} else {
|
||||
priorities[index] = priority;
|
||||
@@ -273,4 +273,4 @@ _ol_structs_PriorityQueue_.prototype.reprioritize = function() {
|
||||
priorities.length = index;
|
||||
this.heapify_();
|
||||
};
|
||||
export default _ol_structs_PriorityQueue_;
|
||||
export default PriorityQueue;
|
||||
|
||||
@@ -15,7 +15,7 @@ import _ol_obj_ from '../obj.js';
|
||||
* @struct
|
||||
* @template T
|
||||
*/
|
||||
var _ol_structs_RBush_ = function(opt_maxEntries) {
|
||||
var RBush = function(opt_maxEntries) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -38,7 +38,7 @@ var _ol_structs_RBush_ = function(opt_maxEntries) {
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.insert = function(extent, value) {
|
||||
RBush.prototype.insert = function(extent, value) {
|
||||
/** @type {ol.RBushEntry} */
|
||||
var item = {
|
||||
minX: extent[0],
|
||||
@@ -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) {
|
||||
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];
|
||||
@@ -84,7 +84,7 @@ _ol_structs_RBush_.prototype.load = function(extents, values) {
|
||||
* @param {T} value Value.
|
||||
* @return {boolean} Removed.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.remove = function(value) {
|
||||
RBush.prototype.remove = function(value) {
|
||||
var uid = getUid(value);
|
||||
|
||||
// get the object in which the value was wrapped when adding to the
|
||||
@@ -100,7 +100,7 @@ _ol_structs_RBush_.prototype.remove = function(value) {
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.update = function(extent, value) {
|
||||
RBush.prototype.update = function(extent, value) {
|
||||
var item = this.items_[getUid(value)];
|
||||
var bbox = [item.minX, item.minY, item.maxX, item.maxY];
|
||||
if (!equals(bbox, extent)) {
|
||||
@@ -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() {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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_th
|
||||
* @return {*} Callback return value.
|
||||
* @template S
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.forEach_ = function(values, callback, opt_this) {
|
||||
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,7 +192,7 @@ _ol_structs_RBush_.prototype.forEach_ = function(values, callback, opt_this) {
|
||||
/**
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.isEmpty = function() {
|
||||
RBush.prototype.isEmpty = function() {
|
||||
return _ol_obj_.isEmpty(this.items_);
|
||||
};
|
||||
|
||||
@@ -200,7 +200,7 @@ _ol_structs_RBush_.prototype.isEmpty = function() {
|
||||
/**
|
||||
* Remove all values from the RBush.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.clear = function() {
|
||||
RBush.prototype.clear = function() {
|
||||
this.rbush_.clear();
|
||||
this.items_ = {};
|
||||
};
|
||||
@@ -210,7 +210,7 @@ _ol_structs_RBush_.prototype.clear = function() {
|
||||
* @param {ol.Extent=} opt_extent Extent.
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.getExtent = function(opt_extent) {
|
||||
RBush.prototype.getExtent = function(opt_extent) {
|
||||
// FIXME add getExtent() to rbush
|
||||
var data = this.rbush_.data;
|
||||
return createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
|
||||
@@ -220,10 +220,10 @@ _ol_structs_RBush_.prototype.getExtent = function(opt_extent) {
|
||||
/**
|
||||
* @param {ol.structs.RBush} rbush R-Tree.
|
||||
*/
|
||||
_ol_structs_RBush_.prototype.concat = function(rbush) {
|
||||
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_;
|
||||
export default RBush;
|
||||
|
||||
Reference in New Issue
Block a user