11 #ifndef TLX_CONTAINER_BTREE_MULTIMAP_HEADER 12 #define TLX_CONTAINER_BTREE_MULTIMAP_HEADER 34 template <
typename Key_,
typename Data_,
35 typename Compare_ = std::less<Key_>,
37 btree_default_traits<Key_, std::pair<Key_, Data_> >,
38 typename Alloc_ = std::allocator<std::pair<Key_, Data_> > >
85 static const key_type&
get(
const value_type& v) {
return v.first; }
185 template <
class InputIterator>
188 : tree_(first, last, alloc)
193 template <
class InputIterator>
195 const key_compare& kcf,
197 : tree_(first, last, kcf, alloc)
257 return tree_.
begin();
269 return tree_.
begin();
274 const_iterator
end()
const {
298 const_reverse_iterator
rend()
const {
315 return tree_.
empty();
343 iterator
find(
const key_type& key) {
344 return tree_.
find(key);
349 const_iterator
find(
const key_type& key)
const {
350 return tree_.
find(key);
355 size_type
count(
const key_type& key)
const {
356 return tree_.
count(key);
389 std::pair<const_iterator, const_iterator>
404 return (tree_ == other.
tree_);
409 return (tree_ != other.
tree_);
415 return (tree_ < other.
tree_);
420 return (tree_ > other.
tree_);
425 return (tree_ <= other.
tree_);
430 return (tree_ >= other.
tree_);
461 return tree_.
insert(x).first;
467 iterator
insert2(
const key_type& key,
const data_type& data) {
473 iterator
insert(iterator hint,
const value_type&
x) {
474 return tree_.
insert(hint, x);
480 const key_type& key,
const data_type& data) {
486 template <
typename InputIterator>
487 void insert(InputIterator first, InputIterator last) {
488 return tree_.
insert(first, last);
494 template <
typename Iterator>
513 size_type
erase(
const key_type& key) {
514 return tree_.
erase(key);
519 return tree_.
erase(iter);
522 #ifdef TLX_BTREE_TODO 525 void erase(iterator , iterator ) {
532 #ifdef TLX_BTREE_DEBUG 541 void print(std::ostream& os)
const {
546 void print_leaves(std::ostream& os)
const {
547 tree_.print_leaves(os);
570 #endif // !TLX_CONTAINER_BTREE_MULTIMAP_HEADER
const_iterator begin() const
iterator find(const key_type &key)
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
BTree< key_type, value_type, key_of_value, key_compare, traits, true, allocator_type > btree_impl
Implementation type of the btree_base.
static const bool allow_duplicates
const_iterator lower_bound(const key_type &key) const
btree_multimap(const key_compare &kcf, const allocator_type &alloc=allocator_type())
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
void erase(iterator iter)
Erase the key/data pair referenced by the iterator.
static const unsigned short inner_slotmax
void clear()
Frees all key/data pairs and all nodes of the tree.
static const bool self_verify
btree_impl::reverse_iterator reverse_iterator
create mutable reverse iterator by using STL magic
Specialized B+ tree template class implementing STL's multimap container.
bool erase_one(const key_type &key)
static const unsigned short leaf_slotmin
btree_multimap(const btree_multimap &other)
size_t size_type
Size type used to count keys.
btree_multimap(InputIterator first, InputIterator last, const key_compare &kcf, const allocator_type &alloc=allocator_type())
btree_impl::const_iterator const_iterator
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
size_type size() const
Return the number of key/data pairs in the B+ tree.
btree_impl::iterator iterator
const struct tree_stats & get_stats() const
Return a const reference to the current statistics.
static const bool self_verify
bool empty() const
Returns true if there is at least one key/data pair in the B+ tree.
void swap(btree_multimap &from)
Fast swapping of two identical B+ tree objects.
void bulk_load(Iterator ibegin, Iterator iend)
btree_impl::tree_stats tree_stats
Small structure containing statistics about the tree.
iterator find(const key_type &key)
void clear()
Frees all key/data pairs and all nodes of the tree.
std::pair< key_type, data_type > value_type
void bulk_load(Iterator first, Iterator last)
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Searches the B+ tree and returns both lower_bound() and upper_bound().
size_type size() const
Return the number of key/data pairs in the B+ tree.
reverse_iterator rbegin()
reverse_iterator rbegin()
static const unsigned short inner_slotmin
iterator insert(const value_type &x)
bool operator>=(const btree_multimap &other) const
Greater-equal relation. Based on operator<.
void insert(InputIterator first, InputIterator last)
const_iterator end() const
void swap(CountingPtr< A, D > &a1, CountingPtr< A, D > &a2) noexcept
btree_multimap & operator=(const btree_multimap &other)
Assignment operator. All the key/data pairs are copied.
size_type max_size() const
iterator upper_bound(const key_type &key)
const_iterator find(const key_type &key) const
size_type count(const key_type &key) const
static const unsigned short leaf_slotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
bool operator<=(const btree_multimap &other) const
Less-equal relation. Based on operator<.
bool operator>(const btree_multimap &other) const
Greater relation. Based on operator<.
~btree_multimap()
Frees up all used B+ tree memory pages.
btree_impl::const_reverse_iterator const_reverse_iterator
create constant reverse iterator by using STL magic
iterator lower_bound(const key_type &key)
const tree_stats & get_stats() const
Return a const reference to the current statistics.
static const unsigned short leaf_slotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
bool exists(const key_type &key) const
size_type erase(const key_type &key)
bool exists(const key_type &key) const
static const unsigned short leaf_slotmin
btree_impl::size_type size_type
Size type used to count keys.
Basic class implementing a B+ tree data structure in memory.
iterator upper_bound(const key_type &key)
iterator insert(iterator hint, const value_type &x)
bool empty() const
Returns true if there is at least one key/data pair in the B+ tree.
allocator_type get_allocator() const
Return the base node allocator provided during construction.
size_type count(const key_type &key) const
static const unsigned short inner_slotmin
size_type max_size() const
btree_impl tree_
The contained implementation object.
allocator_type get_allocator() const
Return the base node allocator provided during construction.
value_compare value_comp() const
bool operator==(const btree_multimap &other) const
const_reverse_iterator rend() const
const_reverse_iterator rbegin() const
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
btree_multimap(InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
Constructor initializing a B+ tree with the range [first,last)
bool operator<(const btree_multimap &other) const
std::pair< iterator, bool > insert(const value_type &x)
value_compare value_comp() const
const_iterator upper_bound(const key_type &key) const
static const unsigned short inner_slotmax
iterator insert2(iterator hint, const key_type &key, const data_type &data)
iterator insert2(const key_type &key, const data_type &data)
Compare_ key_compare
Third template parameter: Key comparison function object.
size_type erase(const key_type &key)
iterator lower_bound(const key_type &key)
static const bool allow_duplicates
Operational parameter: Allow duplicate keys in the btree.
btree_multimap(const allocator_type &alloc=allocator_type())
btree_impl::value_compare value_compare
Function class comparing two value_type pairs.
bool erase_one(const key_type &key)
bool operator!=(const btree_multimap &other) const
Inequality relation. Based on operator==.
Alloc_ allocator_type
Fifth template parameter: STL allocator.