Bounds - binary search using pointer arithmetic
| 164 | |
| 165 | // Bounds - binary search using pointer arithmetic |
| 166 | iterator lower_bound(const Key& key) FL_NOEXCEPT { |
| 167 | // Binary search: find first element where !(element < key) |
| 168 | iterator first = mData.begin(); |
| 169 | size_type count = mData.size(); |
| 170 | |
| 171 | while (count > 0) { |
| 172 | size_type step = count / 2; |
| 173 | iterator it = first + step; |
| 174 | if (mLess(it->first, key)) { |
| 175 | first = it + 1; |
| 176 | count -= step + 1; |
| 177 | } else { |
| 178 | count = step; |
| 179 | } |
| 180 | } |
| 181 | return first; |
| 182 | } |
| 183 | |
| 184 | const_iterator lower_bound(const Key& key) const FL_NOEXCEPT { |
| 185 | // Binary search: find first element where !(element < key) |