diff --git a/fwdpp/ts/recording/edge_buffer.hpp b/fwdpp/ts/recording/edge_buffer.hpp index 8edf923d5..a8c26a07f 100644 --- a/fwdpp/ts/recording/edge_buffer.hpp +++ b/fwdpp/ts/recording/edge_buffer.hpp @@ -31,7 +31,7 @@ namespace fwdpp template using edge_buffer - = nested_forward_lists, std::int32_t, -1>; + = nested_forward_lists, SignedInteger, -1>; // Below are functions for liftover of an edge buffer // to a table collection diff --git a/fwdpp/ts/simplification/simplification.hpp b/fwdpp/ts/simplification/simplification.hpp index 352ace661..ee4070a41 100644 --- a/fwdpp/ts/simplification/simplification.hpp +++ b/fwdpp/ts/simplification/simplification.hpp @@ -228,9 +228,9 @@ namespace fwdpp constexpr SignedInteger segment_overlapper::null; #endif - // FIXME: not generic enough! + template using ancestry_list - = nested_forward_lists, std::int32_t, -1>; + = nested_forward_lists, SignedInteger, -1>; template struct simplifier_internal_state /// Holds data needed during tree sequence simplification @@ -243,7 +243,7 @@ namespace fwdpp typename table_type::edge_table temp_edge_buffer; typename table_type::node_table new_node_table; typename table_type::site_table new_site_table; - ancestry_list ancestry; + ancestry_list ancestry; segment_overlapper overlapper; // NOTE: the whole idea of mutation map could // go away? Should benchmark (later) with @@ -327,29 +327,29 @@ namespace fwdpp template inline void add_ancestry(SignedInteger input_id, double left, double right, - SignedInteger node, ancestry_list& ancestry) + SignedInteger node, ancestry_list& ancestry) { - if (ancestry.head(input_id) == ancestry_list::null) - { - ancestry.extend(input_id, left, right, node); - } + if(ancestry.head(input_id) == ancestry_list::null) + { + ancestry.extend(input_id, left, right, node); + } else - { - auto last_idx = ancestry.tail(input_id); - if (last_idx == ancestry_list::null) - { - throw std::runtime_error("ancestry_list data invalid"); - } - auto& last = ancestry.fetch(last_idx); - if (last.right == left && last.node == node) - { - last.right = right; - } - else - { - ancestry.extend(input_id, left, right, node); - } - } + { + auto last_idx = ancestry.tail(input_id); + if (last_idx == ancestry_list::null) + { + throw std::runtime_error("ancestry_list data invalid"); + } + auto& last = ancestry.fetch(last_idx); + if (last.right == left && last.node == node) + { + last.right = right; + } + else + { + ancestry.extend(input_id, left, right, node); + } + } } template @@ -454,7 +454,7 @@ namespace fwdpp // If the two segments overlap, we add the // minimal overlap to our queue. auto idx = state.ancestry.head(edge_ptr->child); - while (idx != ancestry_list::null) + while (idx != ancestry_list::null) { auto& seg = state.ancestry.fetch(idx); if (seg.right > edge_ptr->left @@ -569,12 +569,12 @@ namespace fwdpp auto seg_idx = state.ancestry.head(n); for (; map_itr < map_end && map_itr->node == n;) { - if (seg_idx == ancestry_list::null) + if (seg_idx == ancestry_list::null) { ++map_itr; break; } - while (seg_idx != ancestry_list::null + while (seg_idx != ancestry_list::null && map_itr < map_end && map_itr->node == n) { auto& seg = state.ancestry.fetch(seg_idx); @@ -652,11 +652,11 @@ namespace fwdpp template inline void queue_children(SignedInteger child, double left, double right, - ancestry_list& ancestry, + ancestry_list& ancestry, segment_overlapper& overlapper) { auto idx = ancestry.head(child); - while (idx != ancestry_list::null) + while (idx != ancestry_list::null) { auto& seg = ancestry.fetch(idx); if (seg.right > left && right > seg.left) @@ -672,7 +672,7 @@ namespace fwdpp inline void process_births_from_buffer(SignedInteger n, edge_buffer& buffer, - ancestry_list& ancestry, + ancestry_list& ancestry, segment_overlapper& overlapper) { static_assert(std::is_integral::value, diff --git a/testsuite/tree_sequences/test_ancestry_list.cc b/testsuite/tree_sequences/test_ancestry_list.cc index a7f4a4a6f..4231daf5c 100644 --- a/testsuite/tree_sequences/test_ancestry_list.cc +++ b/testsuite/tree_sequences/test_ancestry_list.cc @@ -2,10 +2,12 @@ #include #include +using ancestry_list = fwdpp::ts::simplification::ancestry_list; + namespace { std::int64_t - get_list_length(const fwdpp::ts::simplification::ancestry_list& al, std::int32_t i) + get_list_length(const ancestry_list& al, std::int32_t i) { int len = 0; auto f = al.head(i); @@ -25,7 +27,7 @@ BOOST_AUTO_TEST_CASE(test_construct_and_fill) // The data added don't refer to valid // tree sequences and are just for testing { - fwdpp::ts::simplification::ancestry_list al; + ancestry_list al; al.reset(4); al.extend(0, 0., 1., 3); al.extend(1, 0., 0.5, 3); @@ -37,7 +39,7 @@ BOOST_AUTO_TEST_CASE(test_construct_and_fill) BOOST_AUTO_TEST_CASE(test_fill_nullify_once_fill) { - fwdpp::ts::simplification::ancestry_list al; + ancestry_list al; al.reset(4); al.extend(0, 0., 1., 3); al.extend(1, 0., 0.5, 3);