Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
PriorityQueue.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // Reaktoro includes
21 #include <Reaktoro/Common/Types.hpp>
22 
23 namespace Reaktoro {
24 
25 // A queue organized based on priorities that can change dynamically.
27 {
28 public:
31 
34 
37 
40 
45 
47  auto size() const -> Index;
48 
50  auto reset() -> void;
51 
54  auto increment(Index identity) -> void;
55 
57  auto extend() -> void;
58 
60  auto priorities() const -> Deque<Index> const&;
61 
63  auto order() const -> Deque<Index> const&;
64 
65 private:
67  Deque<Index> _priorities;
68 
70  Deque<Index> _order;
71 };
72 
73 } // namespace Reaktoro
Definition: PriorityQueue.hpp:27
auto order() const -> Deque< Index > const &
Return the current order of the tracked entities in the queue.
static auto withInitialPriorities(Deque< Index > const &priorities) -> PriorityQueue
Return a PriorityQueue instance with given initial priorities.
auto extend() -> void
Extend the queue with the introduction of a new tracked entity.
static auto withInitialOrder(Deque< Index > const &order) -> PriorityQueue
Return a PriorityQueue instance with an initial order and zero priorities.
auto increment(Index identity) -> void
Increment the priority of a tracked entity.
auto reset() -> void
Reset the priorities of the tracked entities.
auto priorities() const -> Deque< Index > const &
Return the current priorities of each tracked entity in the queue.
PriorityQueue()
Construct a default instance of PriorityQueue.
static auto withInitialPrioritiesAndOrder(Deque< Index > const &priorities, Deque< Index > const &order) -> PriorityQueue
Return a PriorityQueue instance with given initial priorities and order.
auto size() const -> Index
Return the size of the priority queue.
static auto withInitialSize(Index size) -> PriorityQueue
Return a PriorityQueue instance with given initial size.
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
std::deque< T > Deque
Convenient alias for std::deque<T>.
Definition: Types.hpp:70
auto identity(Index rows, Index cols) -> decltype(MatrixXd::Identity(rows, cols))
Return an expression of an identity matrix.
Definition: Matrix.hpp:576