Use ol.structs.LRUCache template in ol.TileCache

This commit is contained in:
Tom Payne
2013-11-18 17:48:05 +01:00
parent 353555f740
commit 2d6354bb92
+2 -5
View File
@@ -16,7 +16,7 @@ ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
/** /**
* @constructor * @constructor
* @extends {ol.structs.LRUCache} * @extends {ol.structs.LRUCache.<ol.Tile>}
* @param {number=} opt_highWaterMark High water mark. * @param {number=} opt_highWaterMark High water mark.
*/ */
ol.TileCache = function(opt_highWaterMark) { ol.TileCache = function(opt_highWaterMark) {
@@ -48,10 +48,7 @@ ol.TileCache.prototype.canExpireCache = function() {
ol.TileCache.prototype.expireCache = function(usedTiles) { ol.TileCache.prototype.expireCache = function(usedTiles) {
var tile, zKey; var tile, zKey;
while (this.canExpireCache()) { while (this.canExpireCache()) {
tile = /** @type {ol.Tile} */ (this.peekLast()); tile = this.peekLast();
// TODO: Enforce ol.Tile in ol.TileCache#set
goog.asserts.assert(tile instanceof ol.Tile,
'ol.TileCache#expireCache only works with ol.Tile values.');
zKey = tile.tileCoord.z.toString(); zKey = tile.tileCoord.z.toString();
if (zKey in usedTiles && usedTiles[zKey].contains(tile.tileCoord)) { if (zKey in usedTiles && usedTiles[zKey].contains(tile.tileCoord)) {
break; break;