diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-06-06 15:54:41 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-06-06 15:54:41 -0400 |
commit | 8ddab49cc13d809ca75dcd7f645661a3d3cb05c4 (patch) | |
tree | ba1e5f3237dbb7cdc939c35e193f5e6e46845a77 /src/network_set.cpp | |
parent | ac38dd0a5c394eefc39b7a8cf7b96762f18c8b31 (diff) | |
parent | 6f5287b3921c843a6b322ccbdfcbef00a8f16980 (diff) | |
download | lingo-ap-tracker-8ddab49cc13d809ca75dcd7f645661a3d3cb05c4.tar.gz lingo-ap-tracker-8ddab49cc13d809ca75dcd7f645661a3d3cb05c4.tar.bz2 lingo-ap-tracker-8ddab49cc13d809ca75dcd7f645661a3d3cb05c4.zip |
Merge branch 'subway'
Diffstat (limited to 'src/network_set.cpp')
-rw-r--r-- | src/network_set.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/network_set.cpp b/src/network_set.cpp new file mode 100644 index 0000000..6d2a098 --- /dev/null +++ b/src/network_set.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | #include "network_set.h" | ||
2 | |||
3 | void NetworkSet::Clear() { | ||
4 | network_by_item_.clear(); | ||
5 | } | ||
6 | |||
7 | void NetworkSet::AddLink(int id1, int id2) { | ||
8 | if (id2 > id1) { | ||
9 | // Make sure id1 < id2 | ||
10 | std::swap(id1, id2); | ||
11 | } | ||
12 | |||
13 | if (!network_by_item_.count(id1)) { | ||
14 | network_by_item_[id1] = {}; | ||
15 | } | ||
16 | if (!network_by_item_.count(id2)) { | ||
17 | network_by_item_[id2] = {}; | ||
18 | } | ||
19 | |||
20 | network_by_item_[id1].insert({id1, id2}); | ||
21 | network_by_item_[id2].insert({id1, id2}); | ||
22 | } | ||
23 | |||
24 | bool NetworkSet::IsItemInNetwork(int id) const { | ||
25 | return network_by_item_.count(id); | ||
26 | } | ||
27 | |||
28 | const std::set<std::pair<int, int>>& NetworkSet::GetNetworkGraph(int id) const { | ||
29 | return network_by_item_.at(id); | ||
30 | } | ||