13 #ifndef STXXL_CONTAINERS_BTREE_ITERATOR_MAP_HEADER
14 #define STXXL_CONTAINERS_BTREE_ITERATOR_MAP_HEADER
26 template <
class BTreeType>
27 class iterator_map :
private noncopyable
31 typedef typename btree_type::leaf_bid_type
bid_type;
48 return (a.storage < b.storage) || (a.storage == b.storage && a.offset < b.offset);
54 bool operator () (
const Key& a,
const Key& b)
const
65 typedef typename multimap_type::value_type
pair_type;
73 it != m_it2addr.end(); ++it)
75 (it->second)->
btree = b;
86 STXXL_VERBOSE2(
"btree::iterator_map register_iterator addr=" << &it <<
87 " BID: " << it.
bid <<
" POS: " << it.
pos);
92 STXXL_VERBOSE2(
"btree::iterator_map unregister_iterator addr=" << &it <<
93 " BID: " << it.
bid <<
" POS: " << it.
pos);
94 assert(!m_it2addr.empty());
96 std::pair<mmiterator_type, mmiterator_type> range =
97 m_it2addr.equal_range(key);
99 assert(range.first != range.second);
102 for ( ; i != range.second; ++i)
104 assert(it.
bid == i->first.bid);
105 assert(it.
pos == i->first.pos);
107 if (i->second == &it)
115 STXXL_THROW2(std::runtime_error,
"btree::iterator_map::unregister_iterator",
"Panic in btree::iterator_map, can not find and unregister iterator");
117 template <
class OutputContainer>
121 OutputContainer& out)
123 Key firstkey(bid, first_pos);
124 Key lastkey(bid, last_pos);
131 assert(bid == i->first.bid);
132 out.push_back(i->second);
139 it != m_it2addr.end(); ++it)
141 it->second->make_invalid();
147 std::swap(m_it2addr, obj.m_it2addr);
148 change_btree_pointers(m_btree);
149 obj.change_btree_pointers(obj.m_btree);
159 template <
class BTreeType>
168 #endif // !STXXL_CONTAINERS_BTREE_ITERATOR_MAP_HEADER
multimap_type::value_type pair_type
#define STXXL_VERBOSE2(x)
multimap_type::const_iterator mmconst_iterator_type
void swap(iterator_map &obj)
multimap_type::iterator mmiterator_type
iterator_map(btree_type *b)
void unregister_iterator(iterator_base &it)
#define STXXL_BEGIN_NAMESPACE
void find(const bid_type &bid, unsigned_type first_pos, unsigned_type last_pos, OutputContainer &out)
std::multimap< Key, iterator_base *, KeyCmp > multimap_type
#define STXXL_THROW2(exception_type, location, error_message)
Throws exception_type with "Error in [location] : [error_message]".
btree_iterator_base< btree_type > iterator_base
btree_type::leaf_bid_type bid_type
choose_int_types< my_pointer_size >::unsigned_type unsigned_type
Key(const bid_type &b, unsigned_type p)
void change_btree_pointers(btree_type *b)
changes btree pointer in all contained iterators
void register_iterator(iterator_base &it)
#define STXXL_END_NAMESPACE