private float[] GetTile(int tx, int ty) { var key = new Id(tx, ty); if (!Cache.ContainsKey(key)) { var data = GetValues(tx * TileSize, ty * TileSize); if (Cache.Count() == Capacity) { // Evict least recently used tile if cache is full Cache.RemoveFirst(); } // Create tile, put it at the end of tileCache var tile = new Tile(tx, ty, data); Cache.AddLast(key, tile); return(data); } else { var tile = Cache.Get(key); Cache.Remove(key); Cache.AddLast(key, tile); return(tile.Data); } }
private float[] GetTile(int tx, int ty) { var key = new Id(tx, ty); // TODO : Cache initialization... if (Cache == null) { Cache = new DictionaryQueue <Id, Tile>(new EqualityComparerID()); } if (!Cache.ContainsKey(key)) { var data = GetValues(tx * (int)TileSize.x, ty * (int)TileSize.y); if (Cache.Count() == Capacity) { // Evict least recently used tile if cache is full Cache.RemoveFirst(); } // Create tile, put it at the end of tileCache var tile = new Tile(tx, ty, data); Cache.AddLast(key, tile); return(data); } else { var tile = Cache.Get(key); Cache.Remove(key); Cache.AddLast(key, tile); return(tile.Data); } }