Rename _ol_structs_PriorityQueue_ to PriorityQueue
This commit is contained in:
@@ -27,7 +27,7 @@ import _ol_layer_Group_ from './layer/Group.js';
|
|||||||
import _ol_plugins_ from './plugins.js';
|
import _ol_plugins_ from './plugins.js';
|
||||||
import _ol_renderer_Type_ from './renderer/Type.js';
|
import _ol_renderer_Type_ from './renderer/Type.js';
|
||||||
import _ol_size_ from './size.js';
|
import _ol_size_ from './size.js';
|
||||||
import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js';
|
import PriorityQueue from './structs/PriorityQueue.js';
|
||||||
import _ol_transform_ from './transform.js';
|
import _ol_transform_ from './transform.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -875,10 +875,10 @@ _ol_PluggableMap_.prototype.getTilePriority = function(tile, tileSourceKey, tile
|
|||||||
// are outside the visible extent.
|
// are outside the visible extent.
|
||||||
var frameState = this.frameState_;
|
var frameState = this.frameState_;
|
||||||
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
|
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
|
||||||
return _ol_structs_PriorityQueue_.DROP;
|
return PriorityQueue.DROP;
|
||||||
}
|
}
|
||||||
if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
|
if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
|
||||||
return _ol_structs_PriorityQueue_.DROP;
|
return PriorityQueue.DROP;
|
||||||
}
|
}
|
||||||
// Prioritize the highest zoom level tiles closest to the focus.
|
// Prioritize the highest zoom level tiles closest to the focus.
|
||||||
// Tiles at higher zoom levels are prioritized using Math.log(tileResolution).
|
// Tiles at higher zoom levels are prioritized using Math.log(tileResolution).
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {inherits} from './index.js';
|
|||||||
import _ol_TileState_ from './TileState.js';
|
import _ol_TileState_ from './TileState.js';
|
||||||
import _ol_events_ from './events.js';
|
import _ol_events_ from './events.js';
|
||||||
import EventType from './events/EventType.js';
|
import EventType from './events/EventType.js';
|
||||||
import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js';
|
import PriorityQueue from './structs/PriorityQueue.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -18,7 +18,7 @@ import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js';
|
|||||||
*/
|
*/
|
||||||
var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) {
|
var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) {
|
||||||
|
|
||||||
_ol_structs_PriorityQueue_.call(
|
PriorityQueue.call(
|
||||||
this,
|
this,
|
||||||
/**
|
/**
|
||||||
* @param {Array} element Element.
|
* @param {Array} element Element.
|
||||||
@@ -55,14 +55,14 @@ var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_TileQueue_, _ol_structs_PriorityQueue_);
|
inherits(_ol_TileQueue_, PriorityQueue);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_TileQueue_.prototype.enqueue = function(element) {
|
_ol_TileQueue_.prototype.enqueue = function(element) {
|
||||||
var added = _ol_structs_PriorityQueue_.prototype.enqueue.call(this, element);
|
var added = PriorityQueue.prototype.enqueue.call(this, element);
|
||||||
if (added) {
|
if (added) {
|
||||||
var tile = element[0];
|
var tile = element[0];
|
||||||
_ol_events_.listen(tile, EventType.CHANGE,
|
_ol_events_.listen(tile, EventType.CHANGE,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import _ol_renderer_Map_ from '../Map.js';
|
|||||||
import _ol_renderer_Type_ from '../Type.js';
|
import _ol_renderer_Type_ from '../Type.js';
|
||||||
import _ol_source_State_ from '../../source/State.js';
|
import _ol_source_State_ from '../../source/State.js';
|
||||||
import LRUCache from '../../structs/LRUCache.js';
|
import LRUCache from '../../structs/LRUCache.js';
|
||||||
import _ol_structs_PriorityQueue_ from '../../structs/PriorityQueue.js';
|
import PriorityQueue from '../../structs/PriorityQueue.js';
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
import _ol_webgl_ from '../../webgl.js';
|
||||||
import _ol_webgl_Context_ from '../../webgl/Context.js';
|
import _ol_webgl_Context_ from '../../webgl/Context.js';
|
||||||
import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js';
|
import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js';
|
||||||
@@ -113,7 +113,7 @@ var _ol_renderer_webgl_Map_ = function(container, map) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {ol.structs.PriorityQueue.<Array>}
|
* @type {ol.structs.PriorityQueue.<Array>}
|
||||||
*/
|
*/
|
||||||
this.tileTextureQueue_ = new _ol_structs_PriorityQueue_(
|
this.tileTextureQueue_ = new PriorityQueue(
|
||||||
/**
|
/**
|
||||||
* @param {Array.<*>} element Element.
|
* @param {Array.<*>} element Element.
|
||||||
* @return {number} Priority.
|
* @return {number} Priority.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import _ol_obj_ from '../obj.js';
|
|||||||
* @struct
|
* @struct
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) {
|
var PriorityQueue = function(priorityFunction, keyFunction) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {function(T): number}
|
* @type {function(T): number}
|
||||||
@@ -58,13 +58,13 @@ var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) {
|
|||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.DROP = Infinity;
|
PriorityQueue.DROP = Infinity;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME empty description for jsdoc
|
* FIXME empty description for jsdoc
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.clear = function() {
|
PriorityQueue.prototype.clear = function() {
|
||||||
this.elements_.length = 0;
|
this.elements_.length = 0;
|
||||||
this.priorities_.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).
|
* Remove and return the highest-priority element. O(log N).
|
||||||
* @return {T} Element.
|
* @return {T} Element.
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.dequeue = function() {
|
PriorityQueue.prototype.dequeue = function() {
|
||||||
var elements = this.elements_;
|
var elements = this.elements_;
|
||||||
var priorities = this.priorities_;
|
var priorities = this.priorities_;
|
||||||
var element = elements[0];
|
var element = elements[0];
|
||||||
@@ -98,11 +98,11 @@ _ol_structs_PriorityQueue_.prototype.dequeue = function() {
|
|||||||
* @param {T} element Element.
|
* @param {T} element Element.
|
||||||
* @return {boolean} The element was added to the queue.
|
* @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_),
|
_ol_asserts_.assert(!(this.keyFunction_(element) in this.queuedElements_),
|
||||||
31); // Tried to enqueue an `element` that was already added to the queue
|
31); // Tried to enqueue an `element` that was already added to the queue
|
||||||
var priority = this.priorityFunction_(element);
|
var priority = this.priorityFunction_(element);
|
||||||
if (priority != _ol_structs_PriorityQueue_.DROP) {
|
if (priority != PriorityQueue.DROP) {
|
||||||
this.elements_.push(element);
|
this.elements_.push(element);
|
||||||
this.priorities_.push(priority);
|
this.priorities_.push(priority);
|
||||||
this.queuedElements_[this.keyFunction_(element)] = true;
|
this.queuedElements_[this.keyFunction_(element)] = true;
|
||||||
@@ -116,7 +116,7 @@ _ol_structs_PriorityQueue_.prototype.enqueue = function(element) {
|
|||||||
/**
|
/**
|
||||||
* @return {number} Count.
|
* @return {number} Count.
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.getCount = function() {
|
PriorityQueue.prototype.getCount = function() {
|
||||||
return this.elements_.length;
|
return this.elements_.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ _ol_structs_PriorityQueue_.prototype.getCount = function() {
|
|||||||
* @return {number} The index of the left child.
|
* @return {number} The index of the left child.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.getLeftChildIndex_ = function(index) {
|
PriorityQueue.prototype.getLeftChildIndex_ = function(index) {
|
||||||
return index * 2 + 1;
|
return index * 2 + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ _ol_structs_PriorityQueue_.prototype.getLeftChildIndex_ = function(index) {
|
|||||||
* @return {number} The index of the right child.
|
* @return {number} The index of the right child.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.getRightChildIndex_ = function(index) {
|
PriorityQueue.prototype.getRightChildIndex_ = function(index) {
|
||||||
return index * 2 + 2;
|
return index * 2 + 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ _ol_structs_PriorityQueue_.prototype.getRightChildIndex_ = function(index) {
|
|||||||
* @return {number} The index of the parent.
|
* @return {number} The index of the parent.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.getParentIndex_ = function(index) {
|
PriorityQueue.prototype.getParentIndex_ = function(index) {
|
||||||
return (index - 1) >> 1;
|
return (index - 1) >> 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ _ol_structs_PriorityQueue_.prototype.getParentIndex_ = function(index) {
|
|||||||
* Make this a heap. O(N).
|
* Make this a heap. O(N).
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.heapify_ = function() {
|
PriorityQueue.prototype.heapify_ = function() {
|
||||||
var i;
|
var i;
|
||||||
for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) {
|
for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) {
|
||||||
this.siftUp_(i);
|
this.siftUp_(i);
|
||||||
@@ -169,7 +169,7 @@ _ol_structs_PriorityQueue_.prototype.heapify_ = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {boolean} Is empty.
|
* @return {boolean} Is empty.
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.isEmpty = function() {
|
PriorityQueue.prototype.isEmpty = function() {
|
||||||
return this.elements_.length === 0;
|
return this.elements_.length === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ _ol_structs_PriorityQueue_.prototype.isEmpty = function() {
|
|||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @return {boolean} Is key queued.
|
* @return {boolean} Is key queued.
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.isKeyQueued = function(key) {
|
PriorityQueue.prototype.isKeyQueued = function(key) {
|
||||||
return key in this.queuedElements_;
|
return key in this.queuedElements_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ _ol_structs_PriorityQueue_.prototype.isKeyQueued = function(key) {
|
|||||||
* @param {T} element Element.
|
* @param {T} element Element.
|
||||||
* @return {boolean} Is queued.
|
* @return {boolean} Is queued.
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.isQueued = function(element) {
|
PriorityQueue.prototype.isQueued = function(element) {
|
||||||
return this.isKeyQueued(this.keyFunction_(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.
|
* @param {number} index The index of the node to move down.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.siftUp_ = function(index) {
|
PriorityQueue.prototype.siftUp_ = function(index) {
|
||||||
var elements = this.elements_;
|
var elements = this.elements_;
|
||||||
var priorities = this.priorities_;
|
var priorities = this.priorities_;
|
||||||
var count = elements.length;
|
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.
|
* @param {number} index The index of the node to move up.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.siftDown_ = function(startIndex, index) {
|
PriorityQueue.prototype.siftDown_ = function(startIndex, index) {
|
||||||
var elements = this.elements_;
|
var elements = this.elements_;
|
||||||
var priorities = this.priorities_;
|
var priorities = this.priorities_;
|
||||||
var element = elements[index];
|
var element = elements[index];
|
||||||
@@ -252,7 +252,7 @@ _ol_structs_PriorityQueue_.prototype.siftDown_ = function(startIndex, index) {
|
|||||||
/**
|
/**
|
||||||
* FIXME empty description for jsdoc
|
* FIXME empty description for jsdoc
|
||||||
*/
|
*/
|
||||||
_ol_structs_PriorityQueue_.prototype.reprioritize = function() {
|
PriorityQueue.prototype.reprioritize = function() {
|
||||||
var priorityFunction = this.priorityFunction_;
|
var priorityFunction = this.priorityFunction_;
|
||||||
var elements = this.elements_;
|
var elements = this.elements_;
|
||||||
var priorities = this.priorities_;
|
var priorities = this.priorities_;
|
||||||
@@ -262,7 +262,7 @@ _ol_structs_PriorityQueue_.prototype.reprioritize = function() {
|
|||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
element = elements[i];
|
element = elements[i];
|
||||||
priority = priorityFunction(element);
|
priority = priorityFunction(element);
|
||||||
if (priority == _ol_structs_PriorityQueue_.DROP) {
|
if (priority == PriorityQueue.DROP) {
|
||||||
delete this.queuedElements_[this.keyFunction_(element)];
|
delete this.queuedElements_[this.keyFunction_(element)];
|
||||||
} else {
|
} else {
|
||||||
priorities[index] = priority;
|
priorities[index] = priority;
|
||||||
@@ -273,4 +273,4 @@ _ol_structs_PriorityQueue_.prototype.reprioritize = function() {
|
|||||||
priorities.length = index;
|
priorities.length = index;
|
||||||
this.heapify_();
|
this.heapify_();
|
||||||
};
|
};
|
||||||
export default _ol_structs_PriorityQueue_;
|
export default PriorityQueue;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_structs_PriorityQueue_ from '../../../../src/ol/structs/PriorityQueue.js';
|
import PriorityQueue from '../../../../src/ol/structs/PriorityQueue.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.structs.PriorityQueue', function() {
|
describe('ol.structs.PriorityQueue', function() {
|
||||||
@@ -11,7 +11,7 @@ describe('ol.structs.PriorityQueue', function() {
|
|||||||
|
|
||||||
var pq;
|
var pq;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
pq = new _ol_structs_PriorityQueue_(identity, identity);
|
pq = new PriorityQueue(identity, identity);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is empty', function() {
|
it('is empty', function() {
|
||||||
@@ -39,8 +39,7 @@ describe('ol.structs.PriorityQueue', function() {
|
|||||||
var elements, pq;
|
var elements, pq;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
elements = [];
|
elements = [];
|
||||||
pq = new _ol_structs_PriorityQueue_(
|
pq = new PriorityQueue(identity, identity);
|
||||||
identity, identity);
|
|
||||||
var element, i;
|
var element, i;
|
||||||
for (i = 0; i < 32; ++i) {
|
for (i = 0; i < 32; ++i) {
|
||||||
element = Math.random();
|
element = Math.random();
|
||||||
@@ -65,7 +64,7 @@ describe('ol.structs.PriorityQueue', function() {
|
|||||||
var pq, target;
|
var pq, target;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
target = 0.5;
|
target = 0.5;
|
||||||
pq = new _ol_structs_PriorityQueue_(function(element) {
|
pq = new PriorityQueue(function(element) {
|
||||||
return Math.abs(element - target);
|
return Math.abs(element - target);
|
||||||
}, identity);
|
}, identity);
|
||||||
var i;
|
var i;
|
||||||
@@ -103,7 +102,7 @@ describe('ol.structs.PriorityQueue', function() {
|
|||||||
if (i++ % 2 === 0) {
|
if (i++ % 2 === 0) {
|
||||||
return Math.abs(element - target);
|
return Math.abs(element - target);
|
||||||
} else {
|
} else {
|
||||||
return _ol_structs_PriorityQueue_.DROP;
|
return PriorityQueue.DROP;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
pq.reprioritize();
|
pq.reprioritize();
|
||||||
@@ -123,8 +122,7 @@ describe('ol.structs.PriorityQueue', function() {
|
|||||||
|
|
||||||
var pq;
|
var pq;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
pq = new _ol_structs_PriorityQueue_(
|
pq = new PriorityQueue(identity, identity);
|
||||||
identity, identity);
|
|
||||||
pq.enqueue('a');
|
pq.enqueue('a');
|
||||||
pq.enqueue('b');
|
pq.enqueue('b');
|
||||||
pq.enqueue('c');
|
pq.enqueue('c');
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import _ol_Tile_ from '../../../src/ol/Tile.js';
|
|||||||
import _ol_TileQueue_ from '../../../src/ol/TileQueue.js';
|
import _ol_TileQueue_ from '../../../src/ol/TileQueue.js';
|
||||||
import _ol_TileState_ from '../../../src/ol/TileState.js';
|
import _ol_TileState_ from '../../../src/ol/TileState.js';
|
||||||
import _ol_source_Image_ from '../../../src/ol/source/Image.js';
|
import _ol_source_Image_ from '../../../src/ol/source/Image.js';
|
||||||
import _ol_structs_PriorityQueue_ from '../../../src/ol/structs/PriorityQueue.js';
|
import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.TileQueue', function() {
|
describe('ol.TileQueue', function() {
|
||||||
@@ -129,7 +129,7 @@ describe('ol.TileQueue', function() {
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
tq.priorityFunction_ = function() {
|
tq.priorityFunction_ = function() {
|
||||||
if ((i++) % 2 === 0) {
|
if ((i++) % 2 === 0) {
|
||||||
return _ol_structs_PriorityQueue_.DROP;
|
return PriorityQueue.DROP;
|
||||||
}
|
}
|
||||||
return Math.floor(Math.random() * 100);
|
return Math.floor(Math.random() * 100);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user