-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsearch_queue.h
37 lines (32 loc) · 1.25 KB
/
search_queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef SEARCHQUEUE_H
#define SEARCHQUEUE_H
#include "node.h"
#include "zero_scipp_node.h"
#include "scipp_node.h"
#include "fs_node.h"
#include "map.h"
#include <set>
#include <unordered_map>
template <typename NodeType = Node>
class SearchQueue
{
public:
SearchQueue(bool (*cmp)(const NodeType&, const NodeType&) = [](const NodeType& lhs, const NodeType& rhs) {return lhs < rhs;});
bool insert(const Map& map, NodeType node, bool withTime,
bool withOld = false, NodeType old = NodeType(-1, -1));
void erase(const Map& map, NodeType node, bool withTime);
void moveByUpperBound(SearchQueue<NodeType>& other, double threshold,
const Map& map, std::multiset<double>& otherF, bool withTime = false);
void moveByLowerBound(SearchQueue<NodeType>& other, double threshold,
const Map& map, std::multiset<double>& FValues, bool withTime = false);
NodeType getByIndex(const Map& map, NodeType node, bool withTime);
NodeType getFront() const;
bool empty() const;
int size() const;
void clear();
//private:
std::set<NodeType, bool (*)(const NodeType&, const NodeType&)> sortByKey;
std::unordered_map<int, NodeType> sortByIndex;
bool (*cmp)(const NodeType&, const NodeType&);
};
#endif // SEARCHQUEUE_H