//SPDX-FileCopyrightText: 2023 Yury Gubich //SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include #define UNUSED(variable) (void)variable void initPaths(const char* programPath); const std::filesystem::path& sharedPath(); bool endsWith(const std::string& string, const std::string& query); void ltrim(std::string& string); void rtrim(std::string& string); void trim(std::string& string); std::string extract(std::string& string, std::string::size_type begin, std::string::size_type end); template struct FirstGreater { bool operator () (const T& left, const T& right) { return std::get<0>(left) > std::get<0>(right); } }; template > class PriorityQueue { public: explicit PriorityQueue(const Compare& compare = Compare()): container(), compare(compare) {} const Type& top () const { return container.front(); } bool empty () const { return container.empty(); } template void emplace (Args&&... args) { container.emplace_back(std::forward(args)...); std::push_heap(container.begin(), container.end(), compare); } void push (const Type& element) { container.push_back(element); std::push_heap(container.begin(), container.end(), compare); } void push (Type&& element) { container.push_back(std::move(element)); std::push_heap(container.begin(), container.end(), compare); } Type pop () { std::pop_heap(container.begin(), container.end(), compare); Type result = std::move(container.back()); container.pop_back(); return result; } private: Container container; Compare compare; };