forked from MUME/MMapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenericFind.cpp
More file actions
39 lines (32 loc) · 902 Bytes
/
Copy pathGenericFind.cpp
File metadata and controls
39 lines (32 loc) · 902 Bytes
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
38
39
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 The MMapper Authors
#include "GenericFind.h"
#include "../global/Timer.h"
#include "../global/thread_utils.h"
#include "../map/Map.h"
#include "roomfilter.h"
RoomIdSet genericFind(const Map &map, const RoomFilter &f)
{
DECL_TIMER(t, "genericFind (parallel)");
struct TlData final
{
RoomIdSet result;
};
ProgressCounter pc;
TlData tl_data;
thread_utils::parallel_for_each_tl<TlData>(
map.getRooms(),
pc,
[&map, &f](TlData &tl, const RoomId id) {
const auto &room = map.getRawRoom(id);
if (f.filter(room)) {
tl.result.insert(id);
}
},
[&tl_data](auto &tls) {
for (auto &tl : tls) {
tl_data.result.insertAll(tl.result);
}
});
return tl_data.result;
}