libdballe  7.7
index.h
1 /*
2  * memdb/index - map-based index for memdb
3  *
4  * Copyright (C) 2013 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program 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 General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBA_MEMDB_INDEX_H
23 #define DBA_MEMDB_INDEX_H
24 
25 #include <set>
26 #include <map>
27 #include <memory>
28 #include <cstddef>
29 
30 namespace dballe {
31 
32 namespace stl {
33 template<typename T> class SetIntersection;
34 template<typename T> class Sequences;
35 }
36 
37 namespace memdb {
38 
40 template<typename T>
41 struct Index : public std::map< T, std::set<size_t> >
42 {
43  typedef typename std::map< T, std::set<size_t> >::const_iterator const_iterator;
44 
46  const std::set<size_t>* search(const T& el) const;
47 
53  bool search(const T& el, stl::SetIntersection<size_t>& out) const;
54 
67  std::unique_ptr< stl::Sequences<size_t> > search_from(const T& first, bool& found) const;
68 
81  std::unique_ptr< stl::Sequences<size_t> > search_to(const T& end, bool& found) const;
82 
95  std::unique_ptr< stl::Sequences<size_t> > search_between(const T& first, const T& end, bool& found) const;
96 
97 #if 0
98  void query(const const_iterator& begin, const const_iterator& end, const Match<size_t>& filter, BaseResults& res) const;
99  void query(const const_iterator& begin, const const_iterator& end, BaseResults& res) const;
100  void query(const const_iterator& begin, const const_iterator& end, const Match<size_t>* filter, BaseResults& res) const;
101 #endif
102 };
103 
104 }
105 }
106 
107 #endif
108 
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
std::unique_ptr< stl::Sequences< size_t > > search_between(const T &first, const T &end, bool &found) const
Lookup all positions all values between two extremes (first included, second excluded), appending the results to a Sequences.
const std::set< size_t > * search(const T &el) const
Lookup all positions for a value.
Base class for match functors.
Definition: match.h:36
std::unique_ptr< stl::Sequences< size_t > > search_from(const T &first, bool &found) const
Lookup all positions for a value and all values after it, appending the results to a Sequences...
Index element positions based by one value.
Definition: index.h:41
std::unique_ptr< stl::Sequences< size_t > > search_to(const T &end, bool &found) const
Lookup all positions all values before the given one, appending the results to a Sequences.