diff options
Diffstat (limited to 'src/network_set.cpp')
-rw-r--r-- | src/network_set.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/network_set.cpp b/src/network_set.cpp index 6d2a098..2a9e12c 100644 --- a/src/network_set.cpp +++ b/src/network_set.cpp | |||
@@ -21,6 +21,19 @@ void NetworkSet::AddLink(int id1, int id2) { | |||
21 | network_by_item_[id2].insert({id1, id2}); | 21 | network_by_item_[id2].insert({id1, id2}); |
22 | } | 22 | } |
23 | 23 | ||
24 | void NetworkSet::AddLinkToNetwork(int network_id, int id1, int id2) { | ||
25 | if (id2 > id1) { | ||
26 | // Make sure id1 < id2 | ||
27 | std::swap(id1, id2); | ||
28 | } | ||
29 | |||
30 | if (!network_by_item_.count(network_id)) { | ||
31 | network_by_item_[network_id] = {}; | ||
32 | } | ||
33 | |||
34 | network_by_item_[network_id].insert({id1, id2}); | ||
35 | } | ||
36 | |||
24 | bool NetworkSet::IsItemInNetwork(int id) const { | 37 | bool NetworkSet::IsItemInNetwork(int id) const { |
25 | return network_by_item_.count(id); | 38 | return network_by_item_.count(id); |
26 | } | 39 | } |