30 #ifndef _OPENCOG_HANDLE_MAP_H
31 #define _OPENCOG_HANDLE_MAP_H
38 #include <opencog/util/exceptions.h>
54 :
public std::enable_shared_from_this<HandleMap<T>>
63 typedef typename std::map< Handle, T, std::less<Handle> >
InternalMap;
78 typedef std::shared_ptr<HandleMap<T>>
MapPtr;
87 void add(
Handle key, T element)
throw (RuntimeException)
89 std::lock_guard<std::mutex> lck(
_mtx);
97 throw RuntimeException(TRACE_INFO,
98 "attempting to insert duplicated key %ld in hash map",
111 std::lock_guard<std::mutex> lck(
_mtx);
117 throw AssertionException(
118 "HandleMap: key (%ld) does not exist in this map",
133 std::lock_guard<std::mutex> lck(
_mtx);
146 std::lock_guard<std::mutex> lck(
_mtx);
166 std::lock_guard<std::mutex> lck(
_mtx);
177 std::lock_guard<std::mutex> lck(
_mtx);
189 std::lock_guard<std::mutex> lck(
_mtx);
202 MapPtr mp = std::enable_shared_from_this<HandleMap<T>>::shared_from_this();
209 class HandleMapIterator
218 typedef typename std::map<Handle, T>::iterator
iter_type;
224 typedef std::shared_ptr<HandleMap<T>>
MapPtr;
235 std::lock_guard<std::mutex> lck(
map->_mtx);
248 std::lock_guard<std::mutex> lck(
map->_mtx);
261 throw IndexErrorException(TRACE_INFO,
"HandleMapIterator out of bounds");
264 std::lock_guard<std::mutex> lck(
map->_mtx);
276 #endif // _OPENCOG_HANDLE_MAP_H
bool contains(Handle key)
HandleMapIterator(MapPtr m)
std::shared_ptr< HandleMap< T > > MapPtr
red-black tree maps Handle keys to type T elements
HandleMapIterator< T > * keys()
void add(Handle key, T element)
std::shared_ptr< HandleMap< T > > MapPtr
std::map< Handle, T, std::less< Handle > > InternalMap
InternalMap::iterator InternalIterator
std::map< Handle, T >::iterator iter_type