Files
comaps/storage/downloader_queue_universal.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

77 lines
1.2 KiB
C++

#include "storage/downloader_queue_universal.hpp"
#include <algorithm>
namespace storage
{
bool Queue::IsEmpty() const
{
return m_queue.empty();
}
size_t Queue::Count() const
{
return m_queue.size();
}
bool Queue::Contains(CountryId const & country) const
{
return base::IsExist(m_queue, country);
}
void Queue::ForEachCountry(ForEachCountryFunction const & fn) const
{
for (auto const & queuedCountry : m_queue)
{
fn(queuedCountry);
}
}
void Queue::ForEachCountry(ForEachCountryMutable const & fn)
{
for (auto & queuedCountry : m_queue)
{
fn(queuedCountry);
}
}
CountryId const & Queue::GetFirstId() const
{
CHECK(!m_queue.empty(), ());
return m_queue.front().GetCountryId();
}
QueuedCountry const & Queue::GetFirstCountry() const
{
CHECK(!m_queue.empty(), ());
return m_queue.front();
}
void Queue::Remove(const storage::CountryId & id)
{
auto it = std::find(m_queue.begin(), m_queue.end(), id);
if (it != m_queue.end())
m_queue.erase(it);
}
void Queue::PopFront()
{
CHECK(!m_queue.empty(), ());
m_queue.pop_front();
}
void Queue::Append(QueuedCountry && country)
{
m_queue.emplace_back(std::move(country));
m_queue.back().OnCountryInQueue();
}
void Queue::Clear()
{
m_queue.clear();
}
} // namespace storage