Overpass API regression suite coverage (Saxony) / template_db/ranges.h

template_db/ranges.h

19 of 20 instrumented lines run by the suite (95.0%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#ifndef DE__OSM3S___TEMPLATE_DB__RANGES_H
20#define DE__OSM3S___TEMPLATE_DB__RANGES_H
22#include <utility>
23#include <vector>
26template< typename Index >
27class Ranges
29public:
30420066667 q Ranges() {}
3185360619 q Ranges(Index begin, Index end) : data({{ begin, end }}) {}
33 class Iterator
34 {
35 public:
364637310647 q Iterator(typename std::vector< std::pair< Index, Index > >::const_iterator it_) : it(it_) {}
371695208668 q Iterator() {}
38146681789643 q const Index& lower_bound() const { return it->first; }
39275670111643 q const Index& upper_bound() const { return it->second; }
40199582385 q const std::pair< Index, Index >& operator*() const { return *it; }
41 const Iterator& operator++()
424368294642 q {
434368294642 q ++it;
444368294642 q return *this;
454368294642 q }
460 bool operator==(const Iterator& rhs) const { return it == rhs.it; }
47294262711647 q bool operator!=(const Iterator& rhs) const { return it != rhs.it; }
48 private:
49 typename std::vector< std::pair< Index, Index > >::const_iterator it;
50 };
52303463647 q Iterator begin() const { return Iterator(data.begin()); }
534333847647 q Iterator end() const { return Iterator(data.end()); }
5498913617 q bool empty() const { return data.empty(); }
551599514 q void swap(Ranges& rhs) { data.swap(rhs.data); }
57 Ranges intersect(const Ranges& rhs) const;
58 Ranges union_(const Ranges& rhs) const;
59 Ranges skip_start(Index lower_bound) const;
60 void push_back(Index begin, Index end)
6116834370617 q { data.push_back({ begin, end }); }
62 void sort();
64 bool is_global() const
65140538596 q { return data.size() == 1 && data.begin()->first == Index::min() && data.begin()->second == Index::max(); }
6683573616 q static Ranges global() { return Ranges(Index::min(), Index::max()); }
68private:
69 std::vector< std::pair< Index, Index > > data;
70};
73#endif