1 #ifndef TrackingTools_TrajectoryCleaning_src_OtherHashMaps 2 #define TrackingTools_TrajectoryCleaning_src_OtherHashMaps 9 #include <boost/unordered_map.hpp> 10 #include <boost/range.hpp> 11 #include <boost/type_traits.hpp> 12 #include <boost/mpl/and.hpp> 13 #include <boost/mpl/logical.hpp> 14 #include <boost/mpl/assert.hpp> 15 #include <boost/mpl/if.hpp> 32 typename Hasher = boost::hash<K>,
33 typename Equals = std::equal_to<K>,
34 typename Alloc = std::allocator<V> >
37 BOOST_MPL_ASSERT((boost::mpl::and_<boost::has_trivial_destructor<K>, boost::has_trivial_destructor<V> >));
42 typedef typename boost::mpl::if_<typename boost::is_pointer<V>, V, V
const &>
::type 49 void clear(
size_t newBucketSize = 0) {
50 if (newBucketSize != 0) {
91 template <
typename Item>
103 const value_type &
operator*()
const {
return (*it_)(); }
112 bool good()
const {
return (it_ !=
nullptr); }
119 value_iterator
values(K
const &key);
132 typename std::list<KeyItem *>::iterator
138 typename std::list<ValueItem *>::iterator
155 std::cout <<
"Dumping HASH MULTIMAP" << std::endl;
164 std::cout <<
" Buckets (size " << bucketSize_ <<
", capacity " << bucketCapacity_ <<
")";
166 std::cout <<
" [" << row <<
"] " << *
p << std::endl;
170 for (
typename std::list<KeyItem *>::iterator it = keyRows_.begin(),
last = keyRows_.end(); it !=
last;
173 std::cout <<
" Key Row " << row <<
" (of size " << keyRowSize_ <<
")" << std::endl;
175 std::cout <<
" @ " <<
p <<
" [" <<
p->key <<
", @" <<
p->value <<
"], next = " <<
p->next << std::endl;
177 std::cout <<
" ^^^ this was the last valid item." << std::endl;
186 std::cout <<
" Value Items " << std::endl;
187 for (
typename std::list<ValueItem *>::iterator it = valueRows_.begin(),
last = valueRows_.end(); it !=
last;
190 std::cout <<
" Value Row " << row <<
" (of size " << valueRowSize_ <<
")" << std::endl;
192 std::cout <<
" @ " <<
p <<
" [" <<
p->value <<
"], next = " <<
p->next << std::endl;
194 std::cout <<
" ^^^ this was the last valid item." << std::endl;
202 std::cout <<
" End of dump" << std::endl;
206 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
221 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
232 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
252 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
269 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
287 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
295 if (
eq_(curr->
key, key)) {
305 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
313 template <
typename K,
typename V,
typename Hasher,
typename Equals,
typename Alloc>
319 if (
eq_(curr->key, key))
330 template <
typename K,
typename V>
335 typedef typename std::vector<value_type>::iterator
iterator;
338 bool empty()
const {
return data_.empty(); }
339 const_iterator
begin()
const {
return data_.begin(); }
340 const_iterator
end()
const {
return data_.end(); }
341 iterator
begin() {
return data_.begin(); }
342 iterator
end() {
return data_.end(); }
345 for (
typename std::vector<value_type>::iterator it = data_.begin(), ed = data_.end(); it != ed; ++it) {
350 return data_.back().second;
~SimpleAllocHashMultiMap()
ValueItem * valueEndMarker_
ValueItem * nextValueItem_
item_iterator< ValueItem > value_iterator
std::list< ValueItem * > valueRows_
std::pair< K, V > value_type
KeyItem & find_or_insert_(K const &key)
const_iterator begin() const
KeyItemPtrAllocator ptrAlloc_
const_iterator end() const
const Item::value_type value_type
Alloc::template rebind< KeyItem >::other KeyItemAllocator
bool operator!=(const self_type &other) const
const value_type * pointer
BOOST_MPL_ASSERT((boost::mpl::and_< boost::has_trivial_destructor< K >, boost::has_trivial_destructor< V > >))
Container::value_type value_type
SimpleAllocHashMultiMap< K, V, Hasher, Equals, Alloc > map_type
::std::forward_iterator_tag iterator_category
const value_type & reference
std::list< ValueItem * >::iterator currentValueRow_
KeyItem * push_back_(K const &key, KeyItem *next)
ValueItem(ValueItem *next1, value_ref val)
def template(fileName, svg, replaceme="REPLACEME")
void insert(K const &key, value_ref value)
V & operator[](const K &k)
value_iterator values(K const &key)
boost::mpl::if_< typename boost::is_pointer< V >, V, V const & >::type value_ref
Alloc::template rebind< ValueItem >::other ValueItemAllocator
std::vector< value_type >::const_iterator const_iterator
ValueItemAllocator valueAlloc_
const value_type & operator()() const
const value_type & operator()() const
std::vector< value_type > data_
std::vector< value_type >::iterator iterator
KeyItemAllocator keyAlloc_
const value_type & operator*() const
item_iterator< Item > self_type
Alloc::template rebind< KeyItem * >::other KeyItemPtrAllocator
bool operator==(const self_type &other) const
void clear(size_t newBucketSize=0)
item_iterator(const Item *it)
std::list< KeyItem * > keyRows_
const value_type * operator->() const
ptrdiff_t difference_type
KeyItem(KeyItem *next1, K const &key1, ValueItem *val1)
SimpleAllocHashMultiMap(size_t buckets, size_t keyRowSize, size_t valueRowSize, size_t maxRows=50)
std::list< KeyItem * >::iterator currentKeyRow_