about summary refs log tree commit diff stats
path: root/src/network_set.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-06-09 22:43:20 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-06-09 22:43:20 -0400
commit475b7a38f66071ad5713f6f00a49c4e1399e0613 (patch)
tree4dcb76d5bb9e1dbabe19dcbd0cc9676c31f715e6 /src/network_set.cpp
parent829bb6ba7fdbef5c4e6fb9e4eabc0c2f962325ae (diff)
parent14d075e02007aeb53dbadd6c629564ee467cd7b2 (diff)
downloadlingo-ap-tracker-475b7a38f66071ad5713f6f00a49c4e1399e0613.tar.gz
lingo-ap-tracker-475b7a38f66071ad5713f6f00a49c4e1399e0613.tar.bz2
lingo-ap-tracker-475b7a38f66071ad5713f6f00a49c4e1399e0613.zip
Merge branch 'main' into panels
Diffstat (limited to 'src/network_set.cpp')
-rw-r--r--src/network_set.cpp30
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
3void NetworkSet::Clear() {
4 network_by_item_.clear();
5}
6
7void 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
24bool NetworkSet::IsItemInNetwork(int id) const {
25 return network_by_item_.count(id);
26}
27
28const std::set<std::pair<int, int>>& NetworkSet::GetNetworkGraph(int id) const {
29 return network_by_item_.at(id);
30}