Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
sunethwarna committed Jun 5, 2024
1 parent ebea638 commit 359f87e
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions kratos/containers/pointer_vector_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,13 @@ class PointerVectorSet final
mData.push_back(value);
mSortedPartSize = mData.size();
return iterator(mData.end() - 1);
} else if (EqualKeyTo(KeyOf(*value))(*itr_pos)) {
// already found existing element with the same key, hence returning the existing element.
return iterator(itr_pos);
} else {
return UniqueInsert(value);
// insert the new value before the itr_pos.
mSortedPartSize = mData.size() + 1;
return mData.insert(itr_pos, value);
}
}

Expand Down Expand Up @@ -606,7 +611,7 @@ class PointerVectorSet final
return iterator(mData.end() - 1);
} else {
// given position is invalid. Hence, discarding the hint.
return UniqueInsert(value);
return insert(value);
}
} else if (position_hint == cbegin()) {
// trying to insert at the front.
Expand All @@ -617,7 +622,7 @@ class PointerVectorSet final
return mData.insert(mData.begin(), value);
} else {
// given position is invalid. Hence, discarding the hint.
return UniqueInsert(value);
return insert(value);
}
} else {
// trying to insert at an arbitrary position.
Expand All @@ -626,7 +631,7 @@ class PointerVectorSet final
return mData.insert(mData.begin() + (position_hint - cbegin()), value);
} else {
// given position is invalid. Hence, discarding the hint.
return UniqueInsert(value);
return insert(value);
}
}
}
Expand Down Expand Up @@ -1178,19 +1183,6 @@ class PointerVectorSet final
}
}

iterator UniqueInsert(const TPointerType& value)
{
auto itr_pos = std::lower_bound(mData.begin(), mData.end(), KeyOf(*value), CompareKey());
if (EqualKeyTo(KeyOf(*value))(*itr_pos)) {
// already found existing element with the same key, hence returning the existing element.
return iterator(itr_pos);
} else {
// insert the new value before the itr_pos.
mSortedPartSize = mData.size() + 1;
return mData.insert(itr_pos, value);
}
}

///@}
///@name Serialization
///@{
Expand Down

0 comments on commit 359f87e

Please sign in to comment.