XAML-Map-Control/MapControl/Shared/TileQueue.cs
2019-06-10 22:18:02 +02:00

36 lines
806 B
C#

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2019 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace MapControl
{
public class TileQueue : ConcurrentStack<Tile>
{
public void Enqueue(IEnumerable<Tile> tiles)
{
tiles = tiles.Where(tile => tile.Pending);
if (tiles.Any())
{
PushRange(tiles.Reverse().ToArray());
}
}
public bool TryDequeue(out Tile tile)
{
var success = TryPop(out tile);
if (success)
{
tile.Pending = false;
}
return success;
}
}
}