Go to the documentation of this file.
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_> > >
80 typedef std::pair<key_type, data_type>
value_type;
99 typedef typename btree_impl::tree_stats
tree_stats;
144 typedef typename btree_impl::iterator
iterator;
185 template <
class InputIterator>
188 :
tree_(first, last, alloc)
193 template <
class InputIterator>
197 :
tree_(first, last, kcf, alloc)
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_);
486 template <
typename InputIterator>
487 void insert(InputIterator first, InputIterator last) {
494 template <
typename Iterator>
522 #ifdef TLX_BTREE_TODO
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
btree_impl::tree_stats tree_stats
Small structure containing statistics about the tree.
void verify() const
Run a thorough verification of all B+ tree invariants.
value_compare value_comp() const
Constant access to a constructed value_type comparison object.
allocator_type get_allocator() const
Return the base node allocator provided during construction.
Key_ key_type
First template parameter: The key type of the btree.
btree_multimap(const allocator_type &alloc=allocator_type())
Default constructor initializing an empty B+ tree with the standard key comparison function.
bool operator<(const btree_multimap &other) const
Total ordering relation of B+ trees of the same type.
const struct tree_stats & get_stats() const
Return a const reference to the current statistics.
bool erase_one(const key_type &key)
Erases one (the first) of the key/data pairs associated with the given key.
iterator begin()
Constructs a read/data-write iterator that points to the first slot in the first leaf of the B+ tree.
void clear()
Frees all key/data pairs and all nodes of the tree.
void bulk_load(Iterator first, Iterator last)
Bulk load a sorted range [first,last).
iterator upper_bound(const key_type &key)
Searches the B+ tree and returns an iterator to the first pair greater than key, or end() if all keys...
void bulk_load(Iterator ibegin, Iterator iend)
Bulk load a sorted range.
reverse_iterator rbegin()
Constructs a read/data-write reverse iterator that points to the first invalid slot in the last leaf ...
static const bool allow_duplicates
Operational parameter: Allow duplicate keys in the btree.
bool operator!=(const btree_multimap &other) const
Inequality relation. Based on operator==.
static const unsigned short inner_slotmin
Computed B+ tree parameter: The minimum number of key slots used in an inner node.
static const bool debug
Debug parameter: Prints out lots of debug information about how the algorithms change the tree.
iterator insert(const value_type &x)
Attempt to insert a key/data pair into the B+ tree.
btree_impl::value_compare value_compare
Function class comparing two value_type pairs.
static const unsigned short inner_slotmax
Base B+ tree parameter: The number of key slots in each inner node, this can differ from slots in eac...
~btree_multimap()
Frees up all used B+ tree memory pages.
Alloc_ allocator_type
Fifth template parameter: STL allocator.
BTree< key_type, value_type, key_of_value, key_compare, traits, true, allocator_type > btree_impl
Implementation type of the btree_base.
size_type count(const key_type &key) const
Tries to locate a key in the B+ tree and returns the number of identical key entries found.
Traits_ traits
Fourth template parameter: Traits object used to define more parameters of the B+ tree.
std::pair< iterator, bool > insert(const value_type &x)
Attempt to insert a key/data pair into the B+ tree.
size_type max_size() const
Returns the largest possible size of the B+ Tree.
const tree_stats & get_stats() const
Return a const reference to the current statistics.
btree_multimap(InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
Constructor initializing a B+ tree with the range [first,last)
size_type max_size() const
Returns the largest possible size of the B+ Tree.
btree_impl::reverse_iterator reverse_iterator
create mutable reverse iterator by using STL magic
Data_ data_type
Second template parameter: The data type associated with each key.
static const bool debug
Debug parameter: Prints out lots of debug information about how the algorithms change the tree.
bool erase_one(const key_type &key)
Erases one (the first) of the key/data pairs associated with the given key.
void verify() const
Run a thorough verification of all B+ tree invariants.
reverse_iterator rend()
Constructs a read/data-write reverse iterator that points to the first slot in the first leaf of the ...
bool operator==(const btree_multimap &other) const
Equality relation of B+ trees of the same type.
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
static const unsigned short inner_slotmin
Computed B+ tree parameter: The minimum number of key slots used in an inner node.
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
iterator insert2(const key_type &key, const data_type &data)
Attempt to insert a key/data pair into the B+ tree.
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
Compare_ key_compare
Third template parameter: Key comparison function object.
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
allocator_type get_allocator() const
Return the base node allocator provided during construction.
iterator end()
Constructs a read/data-write iterator that points to the first invalid slot in the last leaf of the B...
bool empty() const
Returns true if there is at least one key/data pair in the B+ tree.
static const bool self_verify
Debug parameter: Enables expensive and thorough checking of the B+ tree invariants after each insert/...
value_compare value_comp() const
Constant access to a constructed value_type comparison object.
size_type size() const
Return the number of key/data pairs in the B+ tree.
btree_impl::const_iterator const_iterator
STL-like iterator object for B+ tree items.
iterator lower_bound(const key_type &key)
Searches the B+ tree and returns an iterator to the first pair equal to or greater than key,...
void swap(btree_multimap &from)
Fast swapping of two identical B+ tree objects.
Specialized B+ tree template class implementing STL's multimap container.
reverse_iterator rend()
Constructs a read/data-write reverse iterator that points to the first slot in the first leaf of the ...
size_type erase(const key_type &key)
Erases all the key/data pairs associated with the given key.
void swap(CountingPtr< A, D > &a1, CountingPtr< A, D > &a2) noexcept
swap enclosed object with another counting pointer (no reference counts need change)
void clear()
Frees all key/data pairs and all nodes of the tree.
iterator find(const key_type &key)
Tries to locate a key in the B+ tree and returns an iterator to the key/data slot if found.
iterator find(const key_type &key)
Tries to locate a key in the B+ tree and returns an iterator to the key/data slot if found.
Basic class implementing a B+ tree data structure in memory.
static const key_type & get(const value_type &v)
pull first out of pair
std::pair< key_type, data_type > value_type
Construct the STL-required value_type as a composition pair of key and data types.
iterator end()
Constructs a read/data-write iterator that points to the first invalid slot in the last leaf of the B...
bool operator>=(const btree_multimap &other) const
Greater-equal relation. Based on operator<.
static const unsigned short leaf_slotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
bool empty() const
Returns true if there is at least one key/data pair in the B+ tree.
bool exists(const key_type &key) const
Non-STL function checking whether a key is in the B+ tree.
static const unsigned short leaf_slotmin
Computed B+ tree parameter: The minimum number of key/data slots used in a leaf.
bool operator>(const btree_multimap &other) const
Greater relation. Based on operator<.
static const unsigned short inner_slotmax
Base B+ tree parameter: The number of key slots in each inner node, this can differ from slots in eac...
bool operator<=(const btree_multimap &other) const
Less-equal relation. Based on operator<.
static const unsigned short leaf_slotmin
Computed B+ tree parameter: The minimum number of key/data slots used in a leaf.
iterator begin()
Constructs a read/data-write iterator that points to the first slot in the first leaf of the B+ tree.
iterator lower_bound(const key_type &key)
Searches the B+ tree and returns an iterator to the first pair equal to or greater than key,...
btree_multimap & operator=(const btree_multimap &other)
Assignment operator. All the key/data pairs are copied.
bool exists(const key_type &key) const
Non-STL function checking whether a key is in the B+ tree.
btree_impl::size_type size_type
Size type used to count keys.
size_type count(const key_type &key) const
Tries to locate a key in the B+ tree and returns the number of identical key entries found.
size_type size() const
Return the number of key/data pairs in the B+ tree.
iterator upper_bound(const key_type &key)
Searches the B+ tree and returns an iterator to the first pair greater than key, or end() if all keys...
static const bool allow_duplicates
Sixth template parameter: Allow duplicate keys in the B+ tree.
static const bool self_verify
Debug parameter: Enables expensive and thorough checking of the B+ tree invariants after each insert/...
btree_impl tree_
The contained implementation object.
btree_impl::const_reverse_iterator const_reverse_iterator
create constant reverse iterator by using STL magic
size_t size_type
Size type used to count keys.
reverse_iterator rbegin()
Constructs a read/data-write reverse iterator that points to the first invalid slot in the last leaf ...
static const unsigned short leaf_slotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
size_type erase(const key_type &key)
Erases all the key/data pairs associated with the given key.
btree_impl::iterator iterator
STL-like iterator object for B+ tree items.