Rename _ol_structs_PriorityQueue_ to PriorityQueue

This commit is contained in:
Frederic Junod
2017-12-17 09:04:53 +01:00
parent e887b5012b
commit f96a94fbcd
6 changed files with 36 additions and 38 deletions

View File

@@ -27,7 +27,7 @@ import _ol_layer_Group_ from './layer/Group.js';
import _ol_plugins_ from './plugins.js';
import _ol_renderer_Type_ from './renderer/Type.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';
@@ -875,10 +875,10 @@ _ol_PluggableMap_.prototype.getTilePriority = function(tile, tileSourceKey, tile
// are outside the visible extent.
var frameState = this.frameState_;
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
return _ol_structs_PriorityQueue_.DROP;
return PriorityQueue.DROP;
}
if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
return _ol_structs_PriorityQueue_.DROP;
return PriorityQueue.DROP;
}
// Prioritize the highest zoom level tiles closest to the focus.
// Tiles at higher zoom levels are prioritized using Math.log(tileResolution).

View File

@@ -5,7 +5,7 @@ import {inherits} from './index.js';
import _ol_TileState_ from './TileState.js';
import _ol_events_ from './events.js';
import EventType from './events/EventType.js';
import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js';
import PriorityQueue from './structs/PriorityQueue.js';
/**
* @constructor
@@ -18,7 +18,7 @@ import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js';
*/
var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) {
_ol_structs_PriorityQueue_.call(
PriorityQueue.call(
this,
/**
* @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
*/
_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) {
var tile = element[0];
_ol_events_.listen(tile, EventType.CHANGE,

View File

@@ -16,7 +16,7 @@ import _ol_renderer_Map_ from '../Map.js';
import _ol_renderer_Type_ from '../Type.js';
import _ol_source_State_ from '../../source/State.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_Context_ from '../../webgl/Context.js';
import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js';
@@ -113,7 +113,7 @@ var _ol_renderer_webgl_Map_ = function(container, map) {
* @private
* @type {ol.structs.PriorityQueue.<Array>}
*/
this.tileTextureQueue_ = new _ol_structs_PriorityQueue_(
this.tileTextureQueue_ = new PriorityQueue(
/**
* @param {Array.<*>} element Element.
* @return {number} Priority.

View File

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

View File

@@ -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() {
@@ -11,7 +11,7 @@ describe('ol.structs.PriorityQueue', function() {
var pq;
beforeEach(function() {
pq = new _ol_structs_PriorityQueue_(identity, identity);
pq = new PriorityQueue(identity, identity);
});
it('is empty', function() {
@@ -39,8 +39,7 @@ describe('ol.structs.PriorityQueue', function() {
var elements, pq;
beforeEach(function() {
elements = [];
pq = new _ol_structs_PriorityQueue_(
identity, identity);
pq = new PriorityQueue(identity, identity);
var element, i;
for (i = 0; i < 32; ++i) {
element = Math.random();
@@ -65,7 +64,7 @@ describe('ol.structs.PriorityQueue', function() {
var pq, target;
beforeEach(function() {
target = 0.5;
pq = new _ol_structs_PriorityQueue_(function(element) {
pq = new PriorityQueue(function(element) {
return Math.abs(element - target);
}, identity);
var i;
@@ -103,7 +102,7 @@ describe('ol.structs.PriorityQueue', function() {
if (i++ % 2 === 0) {
return Math.abs(element - target);
} else {
return _ol_structs_PriorityQueue_.DROP;
return PriorityQueue.DROP;
}
};
pq.reprioritize();
@@ -123,8 +122,7 @@ describe('ol.structs.PriorityQueue', function() {
var pq;
beforeEach(function() {
pq = new _ol_structs_PriorityQueue_(
identity, identity);
pq = new PriorityQueue(identity, identity);
pq.enqueue('a');
pq.enqueue('b');
pq.enqueue('c');

View File

@@ -3,7 +3,7 @@ import _ol_Tile_ from '../../../src/ol/Tile.js';
import _ol_TileQueue_ from '../../../src/ol/TileQueue.js';
import _ol_TileState_ from '../../../src/ol/TileState.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() {
@@ -129,7 +129,7 @@ describe('ol.TileQueue', function() {
var i = 0;
tq.priorityFunction_ = function() {
if ((i++) % 2 === 0) {
return _ol_structs_PriorityQueue_.DROP;
return PriorityQueue.DROP;
}
return Math.floor(Math.random() * 100);
};