85 Position_ query_start,
89 std::vector<Index_>& matches)
92 if (subject.root_children == 0) {
145 if (query_end - query_start < params.
min_overlap) {
150 Position_ effective_query_end = query_end;
152 effective_query_end = safe_subtract_gap(query_end, params.
max_gap);
155 auto find_first_child = [&](Index_ children_start, Index_ children_end) -> Index_ {
156 auto ebegin = subject.ends.begin();
157 auto estart = ebegin + children_start;
158 auto eend = ebegin + children_end;
159 return std::lower_bound(estart, eend, effective_query_end) - ebegin;
162 auto is_finished = [&](Position_ subject_start) ->
bool {
163 if (subject_start > query_end) {
170 if (subject_start - query_end > params.
max_gap) {
175 if (query_end - subject_start < params.
min_overlap) {
183 Index_ root_child_at = find_first_child(0, subject.root_children);
185 workspace.history.clear();
187 Index_ current_subject;
188 if (workspace.history.empty()) {
189 if (root_child_at == subject.root_children || is_finished(subject.starts[root_child_at])) {
192 current_subject = root_child_at;
195 auto& current_state = workspace.history.back();
196 if (current_state.child_at == current_state.child_end || is_finished(subject.starts[current_state.child_at])) {
197 workspace.history.pop_back();
200 current_subject = current_state.child_at;
201 ++(current_state.child_at);
204 const auto& current_node = subject.nodes[current_subject];
205 auto subject_start = subject.starts[current_subject];
206 auto subject_end = subject.ends[current_subject];
209 auto common_end = std::min(subject_end, query_end);
210 auto common_start = std::max(subject_start, query_start);
211 if (common_end <= common_start || common_end - common_start < params.
min_overlap) {
220 okay = (subject_end == query_end);
222 okay = !diff_above_gap(query_end, subject_end, params.
max_gap);
226 matches.push_back(current_node.id);
230 if (current_node.duplicates_start != current_node.duplicates_end) {
231 matches.insert(matches.end(), subject.duplicates.begin() + current_node.duplicates_start, subject.duplicates.begin() + current_node.duplicates_end);
235 if (current_node.children_start != current_node.children_end) {
236 Index_ start_pos = find_first_child(current_node.children_start, current_node.children_end);
237 if (start_pos != current_node.children_end) {
238 workspace.history.emplace_back(start_pos, current_node.children_end);
void overlaps_end(const Nclist< Index_, Position_ > &subject, Position_ query_start, Position_ query_end, const OverlapsEndParameters< Position_ > ¶ms, OverlapsEndWorkspace< Index_ > &workspace, std::vector< Index_ > &matches)
Definition overlaps_end.hpp:83