* @brief Inserts a pointer. * @details This function inserts a given pointer such that the resulting PointerVectorSet * is kept sorted. If there exists already a pointer with a key same as the key of the value, then * this will return iterator of that existing pointer (The value will not be inserted.) * @param value The pointer to be inserted. * @return An iterator pointin
| 569 | * @return An iterator pointing to the inserted element. |
| 570 | */ |
| 571 | iterator insert(const TPointerType& value) |
| 572 | { |
| 573 | auto itr_pos = std::lower_bound(mData.begin(), mData.end(), KeyOf(*value), CompareKey()); |
| 574 | if (itr_pos == mData.end()) { |
| 575 | // the position to insert is at the end. |
| 576 | mData.push_back(value); |
| 577 | mSortedPartSize = mData.size(); |
| 578 | return iterator(mData.end() - 1); |
| 579 | } else if (EqualKeyTo(KeyOf(*value))(*itr_pos)) { |
| 580 | // already found existing element with the same key, hence returning the existing element. |
| 581 | return iterator(itr_pos); |
| 582 | } else { |
| 583 | // insert the new value before the itr_pos. |
| 584 | mSortedPartSize = mData.size() + 1; |
| 585 | return mData.insert(itr_pos, value); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | /** |
| 590 | * @brief Inserts a pointer at the specified position. |
no test coverage detected