mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-18 18:20:35 +03:00
util: switch from Boost to std::unordered set/map
This commit replaces the ue2::unordered_{set,map} types with their STL
versions, with some new hashing utilities in util/hash.h. The new types
ue2_unordered_set<T> and ue2_unordered_map<Key, T> default to using the
ue2_hasher.
The header util/ue2_containers.h has been removed, and the flat_set/map
containers moved to util/flat_containers.h.
This commit is contained in:
committed by
Matthew Barr
parent
a425bb9b7c
commit
9cf66b6ac9
@@ -49,11 +49,12 @@
|
||||
#include "util/compile_error.h"
|
||||
#include "util/container.h"
|
||||
#include "util/determinise.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/order_check.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/ue2string.h"
|
||||
#include "util/unordered.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
#include <map>
|
||||
@@ -285,19 +286,16 @@ struct Holder_StateSet {
|
||||
bool operator==(const Holder_StateSet &b) const {
|
||||
return wdelay == b.wdelay && wrap_state == b.wrap_state;
|
||||
}
|
||||
};
|
||||
|
||||
size_t hash_value(const Holder_StateSet &s) {
|
||||
size_t val = 0;
|
||||
boost::hash_combine(val, s.wrap_state);
|
||||
boost::hash_combine(val, s.wdelay);
|
||||
return val;
|
||||
}
|
||||
size_t hash() const {
|
||||
return hash_all(wrap_state, wdelay);
|
||||
}
|
||||
};
|
||||
|
||||
class Automaton_Holder {
|
||||
public:
|
||||
using StateSet = Holder_StateSet;
|
||||
using StateMap = unordered_map<StateSet, dstate_id_t>;
|
||||
using StateMap = ue2_unordered_map<StateSet, dstate_id_t>;
|
||||
|
||||
explicit Automaton_Holder(const NGHolder &g_in) : g(g_in) {
|
||||
for (auto v : vertices_range(g)) {
|
||||
@@ -416,7 +414,7 @@ public:
|
||||
|
||||
private:
|
||||
const NGHolder &g;
|
||||
ue2::unordered_map<NFAVertex, u32> vertexToIndex;
|
||||
unordered_map<NFAVertex, u32> vertexToIndex;
|
||||
vector<NFAVertex> indexToVertex;
|
||||
vector<CharReach> cr_by_index;
|
||||
StateSet init;
|
||||
@@ -712,7 +710,7 @@ int addAutomaton(RoseBuildImpl &build, const NGHolder &h, ReportID *remap) {
|
||||
|
||||
static
|
||||
void setReports(NGHolder &h, const map<NFAVertex, set<u32>> &reportMap,
|
||||
const ue2::unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
|
||||
const unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
|
||||
for (const auto &m : reportMap) {
|
||||
NFAVertex t = orig_to_copy.at(m.first);
|
||||
assert(!m.second.empty());
|
||||
@@ -724,7 +722,7 @@ void setReports(NGHolder &h, const map<NFAVertex, set<u32>> &reportMap,
|
||||
int addAnchoredNFA(RoseBuildImpl &build, const NGHolder &wrapper,
|
||||
const map<NFAVertex, set<u32>> &reportMap) {
|
||||
NGHolder h;
|
||||
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
|
||||
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
|
||||
cloneHolder(h, wrapper, &orig_to_copy);
|
||||
clear_in_edges(h.accept, h);
|
||||
clear_in_edges(h.acceptEod, h);
|
||||
|
||||
Reference in New Issue
Block a user