From ba4a31df421ff47de1f8c3dc86daea2cacd942ed Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 23 Oct 2019 15:25:00 -0400 Subject: added new contains uses --- CMakeLists.txt | 6 +++--- lib/src/network.cpp | 24 ++++++++---------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7477fa..0060968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 3.8) project(fracture) -set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -std=c++2a") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -Wall -march=native -std=c++2a") +set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -std=c++2a -stdlib=libc++") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -Wall -march=native -std=c++2a -stdlib=libc++") -set (CMAKE_CXX_STANDARD 17) +set (CMAKE_CXX_STANDARD 20) set (CMAKE_C_STANDARD 11) include(GNUInstallDirs) diff --git a/lib/src/network.cpp b/lib/src/network.cpp index 98c6eb0..05fc0dd 100644 --- a/lib/src/network.cpp +++ b/lib/src/network.cpp @@ -82,8 +82,7 @@ void network::get_cycle_edges_helper(std::set& cycle_edges, unsigned vn = e[0] == v_cur ? e[1] : e[0]; if (vn != v_prev) { - auto it = seen_vertices.find(vn); - if (it != seen_vertices.end()) { + if (seen_vertices.contains(vn)) { cycle_edges.insert(ei); } else { this->get_cycle_edges_helper(cycle_edges, seen_vertices, v_cur, vn); @@ -106,8 +105,7 @@ bool network::find_cycle_helper(std::array& sig, const std::set& e = G.dual_edges[ei].v; unsigned vn = e[0] == vCur ? e[1] : e[0]; if (vn != vPrev) { @@ -145,8 +143,7 @@ bool network::get_cycle_helper(std::array& sig, std::set& unsigned vPrev, unsigned vCur, unsigned vEnd) const { for (unsigned ei : G.dual_vertices[vCur].ne) { if (fuses[ei]) { - auto it = cycle_edges.find(ei); - if (it == cycle_edges.end()) { + if (!cycle_edges.contains(ei)) { const std::array& e = G.dual_edges[ei].v; unsigned vn = e[0] == vCur ? e[1] : e[0]; if (vn != vPrev) { @@ -186,8 +183,7 @@ std::pair, std::set> network::get_cycle(const void network::get_cluster_edges_helper(std::set& seen_edges, unsigned v) const { for (unsigned ei : G.vertices[v].ne) { if (!backbone[ei]) { - auto it = seen_edges.find(ei); - if (it == seen_edges.end()) { + if (!seen_edges.contains(ei)) { const std::array& e = G.edges[ei].v; unsigned vn = e[0] == v ? e[1] : e[0]; @@ -208,8 +204,7 @@ void network::get_tie_flaps_helper(std::set& added_edges, unsigned v0, unsigned vCur) const { for (unsigned ei : G.vertices[vCur].ne) { if (!backbone[ei]) { - auto it = added_edges.find(ei); - if (it == added_edges.end()) { + if (!added_edges.contains(ei)) { const std::array& e = G.edges[ei].v; unsigned vn = e[0] == vCur ? e[1] : e[0]; @@ -229,8 +224,7 @@ std::list> network::get_tie_flaps(unsigned v0) const { if (!backbone[ei]) { bool seen_edge = false; for (const std::set& flap : tie_flaps) { - auto it = flap.find(ei); - if (it != flap.end()) { + if (flap.contains(ei)) { seen_edge = true; break; } @@ -257,8 +251,7 @@ void network::update_backbone(const std::vector& c) { // First, we will check for lollipops! for (unsigned i = 0; i < G.edges.size(); i++) { if ((!backbone[i]) && C.same_component(G.dual_edges[i].v[0], G.dual_edges[i].v[1])) { - auto it_search = seen_pairs.find({G.dual_edges[i].v[0], G.dual_edges[i].v[1]}); - if (it_search == seen_pairs.end()) { + if (!seen_pairs.contains({G.dual_edges[i].v[0], G.dual_edges[i].v[1]})) { // This is a candidate lollipop stem. First, we will identify any // cycles in the dual cluster that impinges on the stem and mark them // by an edge that uniquely severs each. @@ -377,8 +370,7 @@ void network::update_backbone(const std::vector& c) { if (C.same_component(G.vertices[v].nd[i], G.vertices[v].nd[l])) { unsigned il = i < l ? i : l; unsigned ig = i < l ? l : i; - auto it_search = seen_pairs.find({G.vertices[v].nd[il], G.vertices[v].nd[ig]}); - if (it_search == seen_pairs.end()) { + if (!seen_pairs.contains({G.vertices[v].nd[il], G.vertices[v].nd[ig]})) { bool any_intervening1 = false; bool any_intervening2 = false; unsigned ie1 = 0; -- cgit v1.2.3-54-g00ecf