OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HandleSeqIndex.h
Go to the documentation of this file.
1 /*
2  * opencog/atomspace/HandleSeqIndex.h
3  *
4  * Copyright (C) 2008,2009 Linas Vepstas <linasvepstas@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License v3 as
8  * published by the Free Software Foundation and including the exceptions
9  * at http://opencog.org/wiki/Licenses
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program; if not, write to:
18  * Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef _OPENCOG_HANDLE_SEQ_INDEX_H
23 #define _OPENCOG_HANDLE_SEQ_INDEX_H
24 
25 #include <cstddef>
26 #include <map>
27 
29 
30 namespace opencog
31 {
51 {
52  private:
53  std::map<const HandleSeq, Handle, handle_seq_less> idx;
54 
55  public:
56  void insert(const HandleSeq& seq, const Handle& h)
57  {
58  idx.insert(std::pair<const HandleSeq,Handle>(seq, h));
59  }
60  const Handle& get(const HandleSeq& seq) const
61  {
62  std::map<const HandleSeq, Handle>::const_iterator it;
63  it = idx.find(seq);
64  if (it != idx.end()) return it->second;
65  return Handle::UNDEFINED;
66  }
67  void remove(const HandleSeq& seq)
68  {
69  idx.erase(seq);
70  }
71  size_t size(void) const
72  {
73  return idx.size();
74  }
75  void remove(bool (*)(const Handle&));
76 };
77 
79 } //namespace opencog
80 
81 #endif // _OPENCOG_HANDLE_SEQ_INDEX_H
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
static const Handle UNDEFINED
Definition: Handle.h:77
void insert(const HandleSeq &seq, const Handle &h)
std::map< const HandleSeq, Handle, handle_seq_less > idx
size_t size(void) const