34 #ifndef _STX_BTREE_MULTISET_H_
35 #define _STX_BTREE_MULTISET_H_
60 template <
typename _Key,
61 typename _Compare = std::less<_Key>,
62 typename _Traits = btree_default_set_traits<_Key>,
63 typename _Alloc = std::allocator<_Key> >
195 template <
class InputIterator>
205 template <
class InputIterator>
206 inline btree_multiset(InputIterator first, InputIterator last,
const key_compare &kcf,
221 std::swap(tree, from.tree);
284 inline const_iterator
end()
const
305 inline const_reverse_iterator
rbegin()
const
312 inline const_reverse_iterator
rend()
const
357 iterator
find(
const key_type &key)
359 return tree.
find(key);
364 const_iterator
find(
const key_type &key)
const
366 return tree.
find(key);
371 size_type
count(
const key_type &key)
const
373 return tree.
count(key);
407 inline std::pair<iterator, iterator>
equal_range(
const key_type& key)
413 inline std::pair<const_iterator, const_iterator>
equal_range(
const key_type& key)
const
425 return (tree == other.tree);
431 return (tree != other.tree);
438 return (tree < other.tree);
444 return (tree > other.tree);
450 return (tree <= other.tree);
456 return (tree >= other.tree);
484 inline iterator
insert(
const key_type& x)
491 inline iterator
insert(iterator hint,
const key_type &x)
498 template <
typename InputIterator>
499 inline void insert(InputIterator first, InputIterator last)
501 InputIterator iter = first;
512 template <
typename Iterator>
529 size_type
erase(
const key_type &key)
531 return tree.
erase(key);
537 return tree.
erase(iter);
584 void dump(std::ostream &os)
const
601 #endif // _STX_BTREE_MULTISET_H_
void print(std::ostream &os) const
Print out the B+ tree structure with keys onto the given ostream.
size_type erase(const key_type &key)
Erases all the entries of the given key.
static const bool selfverify
Debug parameter: Enables expensive and thorough checking of the B+ tree invariants after each insert/...
self & operator=(const self &other)
*** Fast Copy: Assign Operator and Copy Constructors
static const bool debug
Debug parameter: Prints out lots of debug information about how the algorithms change the tree...
size_type size() const
Return the number of key/data pairs in the B+ tree.
btree_multiset(const key_compare &kcf, const allocator_type &alloc=allocator_type())
Constructor initializing an empty B+ tree with a special key comparison object.
size_t size_type
Size type used to count keys.
bool operator>=(const self &other) const
Greater-equal relation. Based on operator<.
~btree_multiset()
Frees up all used B+ tree memory pages.
bool operator<=(const self &other) const
Less-equal relation. Based on operator<.
value_compare value_comp() const
Constant access to a constructed value_type comparison object.
Basic class implementing a base B+ tree data structure in memory.
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
bool operator==(const self &other) const
Equality relation of B+ trees of the same type.
size_type erase(const key_type &key)
Erases all the key/data pairs associated with the given key.
std::pair< iterator, iterator > equal_range(const key_type &key)
Searches the B+ tree and returns both lower_bound() and upper_bound().
_Compare key_compare
Second template parameter: Key comparison function object.
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 max_size() const
Returns the largest possible size of the B+ Tree.
btree_multiset(const allocator_type &alloc=allocator_type())
Default constructor initializing an empty B+ tree with the standard key comparison function...
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...
static const bool debug
Debug parameter: Prints out lots of debug information about how the algorithms change the tree...
void verify() const
Run a thorough verification of all B+ tree invariants.
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...
const_iterator begin() const
Constructs a read-only constant iterator that points to the first slot in the first leaf of the B+ tr...
reverse_iterator rend()
Constructs a read/data-write reverse iterator that points to the first slot in the first leaf of the ...
value_compare value_comp() const
Constant access to a constructed value_type comparison object.
void bulk_load(Iterator first, Iterator last)
Bulk load a sorted range [first,last).
bool restore(std::istream &is)
Restore a binary image of a dumped B+ tree from an istream.
void bulk_load(Iterator ibegin, Iterator iend)
Bulk load a sorted range.
Specialized B+ tree template class implementing STL's multiset container.
static const unsigned short leafslotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
static const unsigned short mininnerslots
Computed B+ tree parameter: The minimum number of key slots used in an inner node.
btree_impl::value_compare value_compare
Function class comparing two value_type keys.
#define BTREE_FRIENDS
The macro BTREE_FRIENDS can be used by outside class to access the B+ tree internals.
key_compare key_comp() const
Constant access to the key comparison object sorting the B+ tree.
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...
stx::btree< key_type, data_type, value_type, key_compare, traits, true, allocator_type, true > btree_impl
Implementation type of the btree_base.
bool operator!=(const self &other) const
Inequality relation. Based on operator==.
std::pair< iterator, bool > insert2(const key_type &key, const data_type &data)
Attempt to insert a key/data pair into the B+ tree.
void insert(InputIterator first, InputIterator last)
Attempt to insert the range [first,last) of key_type into the B+ tree.
reverse_iterator rbegin()
Constructs a read/data-write reverse iterator that points to the first invalid slot in the last leaf ...
allocator_type get_allocator() const
Return the base node allocator provided during construction.
_Traits traits
Third template parameter: Traits object used to define more parameters of the B+ tree.
bool operator>(const self &other) const
Greater relation. Based on operator<.
const_iterator find(const key_type &key) const
Tries to locate a key in the B+ tree and returns an constant iterator to the key slot if found...
btree_impl::iterator iterator
STL-like iterator object for B+ tree items.
bool exists(const key_type &key) const
Non-STL function checking whether a key is in the B+ tree.
bool erase_one(const key_type &key)
Erases one (the first) entry of the given key.
btree_multiset(InputIterator first, InputIterator last, const key_compare &kcf, const allocator_type &alloc=allocator_type())
Constructor initializing a B+ tree with the range [first,last) and a special key comparison object...
Contains the main B+ tree implementation template class btree.
void print_leaves(std::ostream &os) const
Print out only the leaves via the double linked list.
const_reverse_iterator rbegin() const
Constructs a read-only reverse iterator that points to the first invalid slot in the last leaf of the...
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...
reverse_iterator rend()
Constructs a read/data-write reverse iterator that points to the first slot in the first leaf of the ...
btree_multiset(const self &other)
Copy constructor.
static const unsigned short leafslotmax
Base B+ tree parameter: The number of key/data slots in each leaf.
static const unsigned short innerslotmax
Base B+ tree parameter: The number of key slots in each inner node, this can differ from slots in eac...
iterator begin()
Constructs a read/data-write iterator that points to the first slot in the first leaf of the B+ tree...
bool empty() const
Returns true if there is at least one key/data pair in the B+ tree.
key_compare key_comp() const
Constant access to the key comparison object sorting 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...
static const unsigned short minleafslots
Computed B+ tree parameter: The minimum number of key slots used in a leaf.
const_iterator upper_bound(const key_type &key) const
Searches the B+ tree and returns a constant iterator to the first pair greater than key...
bool erase_one(const key_type &key)
Erases one (the first) of the key/data pairs associated with the given key.
const struct tree_stats & get_stats() const
Return a const reference to the current statistics.
void dump(std::ostream &os) const
Dump the contents of the B+ tree out onto an ostream as a binary image.
static const bool allow_duplicates
Sixth template parameter: Allow duplicate keys in the B+ tree.
bool exists(const key_type &key) const
Non-STL function checking whether a key is in the B+ tree.
btree_impl::reverse_iterator reverse_iterator
create mutable reverse iterator by using STL magic
btree_multiset(InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
Constructor initializing a B+ tree with the range [first,last)
btree_impl::const_reverse_iterator const_reverse_iterator
create constant reverse iterator by using STL magic
bool empty() const
Returns true if there is at least one key in the B+ tree.
iterator find(const key_type &key)
Tries to locate a key in the B+ tree and returns an iterator to the key slot if found.
void erase(iterator iter)
Erase the key/data pair referenced by the iterator.
iterator begin()
Constructs a read/data-write iterator that points to the first slot in the first leaf of the B+ 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...
btree_impl::tree_stats tree_stats
Small structure containing statistics about the tree.
void dump(std::ostream &os) const
Dump the contents of the B+ tree out onto an ostream as a binary image.
const tree_stats & get_stats() const
Return a const reference to the current statistics.
iterator end()
Constructs a read/data-write iterator that points to the first invalid slot in the last leaf of the B...
static const bool selfverify
Debug parameter: Enables expensive and thorough checking of the B+ tree invariants after each insert/...
void print_leaves(std::ostream &os) const
Print out only the leaves via the double linked list.
The empty struct used as a placeholder for the data_type.
_Alloc allocator_type
Fourth template parameter: STL allocator.
static const bool allow_duplicates
Operational parameter: Allow duplicate keys in the btree.
iterator insert(iterator hint, const key_type &x)
Attempt to insert a key into the B+ tree.
size_type size() const
Return the number of keys in the B+ tree.
const_iterator lower_bound(const key_type &key) const
Searches the B+ tree and returns a constant iterator to the first pair equal to or greater than key...
void swap(self &from)
Fast swapping of two identical B+ tree objects.
btree_impl tree
The contained implementation object.
bool operator<(const self &other) const
Total ordering relation of B+ trees of the same type.
void verify() const
Run a thorough verification of all B+ tree invariants.
static const unsigned short minleafslots
Computed B+ tree parameter: The minimum number of key/data slots used in a leaf.
size_type max_size() const
Returns the largest possible size of the B+ Tree.
static const unsigned short mininnerslots
Computed B+ tree parameter: The minimum number of key slots used in an inner node.
iterator end()
Constructs a read/data-write iterator that points to the first invalid slot in the last leaf of the B...
_Key key_type
First template parameter: The key type of the btree.
void erase(iterator, iterator)
Erase all keys in the range [first,last).
struct empty_struct data_type
The empty data_type.
key_type value_type
Construct the set value_type: the key_type.
btree_impl::const_iterator const_iterator
STL-like iterator object for B+ tree items.
void print(std::ostream &os) const
Print out the B+ tree structure with keys onto the given ostream.
const_iterator end() const
Constructs a read-only constant iterator that points to the first invalid slot in the last leaf of th...
bool restore(std::istream &is)
Restore a binary image of a dumped B+ tree from an istream.
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 innerslotmax
Base B+ tree parameter: The number of key slots in each inner node, this can differ from slots in eac...
allocator_type get_allocator() const
Return the base node allocator provided during construction.
const_reverse_iterator rend() const
Constructs a read-only reverse iterator that points to the first slot in the first leaf of the B+ tre...
void clear()
Frees all key/data pairs and all nodes of the 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...
btree_impl::size_type size_type
Size type used to count keys.
STX - Some Template Extensions namespace.
iterator insert(const key_type &x)
Attempt to insert a key into the B+ tree.
void clear()
Frees all keys and all nodes of the tree.