X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fweighted_btree.h;h=86063c3ae98355ac73fa33fc7149ef6a84eb95fb;hb=7b0f9d95248820bc70b820dd6b558de4a6713bae;hp=0982049b3cf2e8e874e73f472307c1f4c33f2883;hpb=f496c8cdd623545a35ab5778b26db38878f63a3d;p=lyx.git diff --git a/src/support/weighted_btree.h b/src/support/weighted_btree.h index 0982049b3c..86063c3ae9 100644 --- a/src/support/weighted_btree.h +++ b/src/support/weighted_btree.h @@ -29,6 +29,7 @@ // *** Required Headers from the STL #include +#include #include #include #include @@ -150,7 +151,7 @@ public: /// typedef _Weight weight_type; - + /// Second template parameter: The data type associated with each /// key. Stored in the B+ tree's leaves typedef _Data data_type; @@ -1323,7 +1324,7 @@ public: leaf_node *leaf = static_cast(n); - int slot = find_lower(leaf, key); + unsigned short slot = find_lower(leaf, key); return (slot < leaf->slotuse && key_equal(key, leaf->slotkey[slot])) ? iterator(leaf, slot) : end(); } @@ -1376,7 +1377,7 @@ public: leaf_node *leaf = static_cast(n); - int slot = find_summed_weight_lower(leaf, weight); + unsigned short slot = find_summed_weight_lower(leaf, weight); for (unsigned short s = 0; s < slot; ++s) weight -= leaf->weights[s]; @@ -1518,13 +1519,13 @@ public: return iterator(leaf, slot); } - /// Searches the B+ tree and returns an iterator to the first summed weight + /// Searches the B+ tree and returns an iterator to the first summed weight /// less or equal to the parameter. If unsuccessful it returns end(). iterator lower_summed_weight_bound(weight_type weight) { node *n = root; if (!n) return end(); - + while(!n->isleafnode()) { const inner_node *inner = static_cast(n); int slot = find_summed_weight_lower(inner, weight); @@ -1566,7 +1567,7 @@ public: return const_iterator(leaf, slot); } - /// Searches the B+ tree and returns an iterator to the first summed weight + /// Searches the B+ tree and returns an iterator to the first summed weight /// less or equal to the parameter. If unsuccessful it returns end(). const_iterator lower_summed_weight_bound(weight_type weight) const { @@ -1636,7 +1637,7 @@ public: return const_iterator(leaf, slot); } - /// Searches the B+ tree and returns an iterator to the first summed weight + /// Searches the B+ tree and returns an iterator to the first summed weight /// greater than the parameter. If unsuccessful it returns end(). iterator upper_summed_weight_bound(weight_type weight) { @@ -1664,7 +1665,7 @@ public: return iterator(leaf, slot); } - /// Searches the B+ tree and returns an iterator to the first summed weight + /// Searches the B+ tree and returns an iterator to the first summed weight /// greater than the parameter. If unsuccessful it returns end(). const_iterator upper_summed_weight_bound(weight_type weight) const { @@ -1768,7 +1769,7 @@ public: clear(); key_less = other.key_comp(); - if (other.size() != 0) + if (!other.empty()) { stats.leaves = stats.innernodes = 0; root = copy_recursive(other.root); @@ -1787,7 +1788,7 @@ public: stats( other.stats ), key_less( other.key_comp() ) { - if (size() > 0) + if (!empty()) { stats.leaves = stats.innernodes = 0; root = copy_recursive(other.root); @@ -2022,7 +2023,7 @@ private: slot -= inner->slotuse+1; inner = static_cast(*splitnode); - BTREE_PRINT("btree::insert_descend switching to splitted node " << inner << " slot " << slot <(n); - int slot = find_lower(leaf, key); + unsigned short slot = find_lower(leaf, key); if (!allow_duplicates && slot < leaf->slotuse && key_equal(key, leaf->slotkey[slot])) { return std::pair(iterator(leaf, slot), false);