void ossimFixedTileCache::deleteTile()
{
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
   if(theUseLruFlag)
   {
      if(theLruQueue.begin() != theLruQueue.end())
      {
         deleteTile(*(theLruQueue.begin()));
      }
   }
}
Example #2
0
PRIVATE void slideTiles(MAKE_THIS(MainWindow), int xDirection, int yDirection){ SELFREF_INIT;
	int traversX[4], traversY[4], i, y, j, x;
	struct coords farthestCoords;
	BOOL moved = FALSE;

	for (i = 0; i < 4; i++){
		traversX[i] = xDirection < 0 ? i : 3 - i;
		traversY[i] = yDirection < 0 ? i : 3 - i;
	}

	for (i = 0, y = traversY[i]; i < 4; i++, y = traversY[i]){
		for (j = 0, x = traversX[j]; j < 4; j++, x = traversX[j]){
			if (this->tiles[y][x]){
				farthestCoords = findFarthest(this, this->tiles[y][x], xDirection, yDirection);

				if (farthestCoords.x != x || farthestCoords.y != y){
					if (this->tiles[farthestCoords.y][farthestCoords.x]){ /* We need a merger! */
						deleteTile(this->tiles[farthestCoords.y][farthestCoords.x]);
						this->tiles[farthestCoords.y][farthestCoords.x] = NULL;
						this->tiles[y][x]->merged = TRUE;
						$(this->tiles[y][x])_incNumber();
					}

					$(this->tiles[y][x])_moveTile(farthestCoords.y, farthestCoords.x);
					swapTiles(this->tiles, y, x, farthestCoords.y, farthestCoords.x);
					moved = TRUE;
				}
			}
		}
	}

	if (moved){
		for (i = 0; i < 4; i++)
			for (j = 0; j < 4; j++)
				if (this->tiles[i][j])
					this->tiles[i][j]->merged = FALSE;
		addRandomTile(this);
	}

	flushMessageQueue();
}