11 #ifndef TLX_CONTAINER_BTREE_MULTISET_HEADER 12 #define TLX_CONTAINER_BTREE_MULTISET_HEADER 37 template <
typename Key_,
38 typename Compare_ = std::less<Key_>,
39 typename Traits_ = btree_default_traits<Key_, Key_>,
40 typename Alloc_ = std::allocator<Key_> >
81 static const key_type&
get(
const value_type& v) {
return v; }
181 template <
class InputIterator>
190 template <
class InputIterator>
192 const key_compare& kcf,
194 : tree_(kcf, alloc) {
255 return tree_.
begin();
267 return tree_.
begin();
272 const_iterator
end()
const {
296 const_reverse_iterator
rend()
const {
313 return tree_.
empty();
341 iterator
find(
const key_type& key) {
342 return tree_.
find(key);
347 const_iterator
find(
const key_type& key)
const {
348 return tree_.
find(key);
353 size_type
count(
const key_type& key)
const {
354 return tree_.
count(key);
388 const key_type& key)
const {
401 return (tree_ == other.
tree_);
406 return (tree_ != other.
tree_);
412 return (tree_ < other.
tree_);
417 return (tree_ > other.
tree_);
422 return (tree_ <= other.
tree_);
427 return (tree_ >= other.
tree_);
458 return tree_.
insert(x).first;
463 iterator
insert(iterator hint,
const key_type&
x) {
464 return tree_.
insert(hint, x);
469 template <
typename InputIterator>
470 void insert(InputIterator first, InputIterator last) {
471 InputIterator iter = first;
482 template <
typename Iterator>
500 size_type
erase(
const key_type& key) {
501 return tree_.
erase(key);
506 return tree_.
erase(iter);
509 #ifdef TLX_BTREE_TODO 512 void erase(iterator , iterator ) {
519 #ifdef TLX_BTREE_DEBUG 528 void print(std::ostream& os)
const {
533 void print_leaves(std::ostream& os)
const {
534 tree_.print_leaves(os);
557 #endif // !TLX_CONTAINER_BTREE_MULTISET_HEADER bool operator<=(const btree_multiset &other) const
Less-equal relation. Based on operator<.
Specialized B+ tree template class implementing STL's multiset container.
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().
static const bool allow_duplicates
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
static const unsigned short leaf_slotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
size_type count(const key_type &key) const
Compare_ key_compare
Second template parameter: Key comparison function object.
static const bool self_verify
const_iterator lower_bound(const key_type &key) const
btree_impl::tree_stats tree_stats
Small structure containing statistics about the tree.
bool erase_one(const key_type &key)
reverse_iterator rbegin()
btree_multiset(InputIterator first, InputIterator last, const key_compare &kcf, const allocator_type &alloc=allocator_type())
iterator find(const key_type &key)
bool operator!=(const btree_multiset &other) const
Inequality relation. Based on operator==.
btree_impl tree_
The contained implementation object.
size_t size_type
Size type used to count keys.
const_iterator begin() const
BTree< key_type, value_type, key_of_value, key_compare, traits, true, allocator_type > btree_impl
Implementation type of the btree_base.
key_type value_type
Construct the set value_type: the key_type.
const struct tree_stats & get_stats() const
Return a const reference to the current statistics.
bool empty() const
Returns true if there is at least one key in the B+ tree.
size_type max_size() const
btree_multiset(const key_compare &kcf, const allocator_type &alloc=allocator_type())
value_compare value_comp() const
void bulk_load(Iterator first, Iterator last)
static const bool allow_duplicates
Operational parameter: Allow duplicate keys in the btree.
const tree_stats & get_stats() const
Return a const reference to the current statistics.
size_type size() const
Return the number of keys in the B+ tree.
void bulk_load(Iterator ibegin, Iterator iend)
btree_impl::value_compare value_compare
Function class comparing two value_type keys.
void clear()
Frees all key/data pairs and all nodes of the tree.
Alloc_ allocator_type
Fourth template parameter: STL allocator.
allocator_type get_allocator() const
Return the base node allocator provided during construction.
size_type size() const
Return the number of key/data pairs in the B+ tree.
reverse_iterator rbegin()
iterator insert(const key_type &x)
static const unsigned short inner_slotmax
bool erase_one(const key_type &key)
Erases one (the first) entry of the given key.
iterator lower_bound(const key_type &key)
~btree_multiset()
Frees up all used B+ tree memory pages.
void swap(CountingPtr< A, D > &a1, CountingPtr< A, D > &a2) noexcept
size_type max_size() const
btree_multiset(InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
Constructor initializing a B+ tree with the range [first,last)
btree_impl::iterator iterator
bool operator>(const btree_multiset &other) const
Greater relation. Based on operator<.
btree_impl::reverse_iterator reverse_iterator
create mutable reverse iterator by using STL magic
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
void clear()
Frees all keys and all nodes of the tree.
static const unsigned short leaf_slotmin
btree_multiset & operator=(const btree_multiset &other)
Assignment operator. All the keys are copied.
static const unsigned short leaf_slotmin
static const bool self_verify
btree_impl::size_type size_type
Size type used to count keys.
const_iterator upper_bound(const key_type &key) const
Basic class implementing a B+ tree data structure in memory.
iterator upper_bound(const key_type &key)
bool empty() const
Returns true if there is at least one key/data pair in the B+ tree.
btree_impl::const_reverse_iterator const_reverse_iterator
create constant reverse iterator by using STL magic
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
btree_impl::const_iterator const_iterator
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().
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
std::pair< iterator, bool > insert(const value_type &x)
value_compare value_comp() const
static const unsigned short inner_slotmax
btree_multiset(const allocator_type &alloc=allocator_type())
bool exists(const key_type &key) const
void erase(iterator iter)
Erase the key/data pair referenced by the iterator.
static const unsigned short inner_slotmin
size_type erase(const key_type &key)
iterator lower_bound(const key_type &key)
const_iterator find(const key_type &key) const
const_iterator end() const
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
bool operator>=(const btree_multiset &other) const
Greater-equal relation. Based on operator<.
iterator insert(iterator hint, const key_type &x)
const_reverse_iterator rend() const
const_reverse_iterator rbegin() const
void swap(btree_multiset &from)
Fast swapping of two identical B+ tree objects.
void insert(InputIterator first, InputIterator last)
bool operator<(const btree_multiset &other) const
iterator upper_bound(const key_type &key)
btree_multiset(const btree_multiset &other)
size_type erase(const key_type &key)
bool operator==(const btree_multiset &other) const