| 54 | |
| 55 | // Comparator that compares only keys |
| 56 | struct PairCompareWithId { |
| 57 | Compare mComp; |
| 58 | |
| 59 | PairCompareWithId(const Compare& comp = Compare()) : mComp(comp) {} |
| 60 | |
| 61 | bool operator()(const ValueWithId& a, const ValueWithId& b) const { |
| 62 | // Compare keys; if keys are equal, compare IDs to maintain stable order |
| 63 | if (mComp(a.value.first, b.value.first)) { |
| 64 | return true; |
| 65 | } |
| 66 | if (mComp(b.value.first, a.value.first)) { |
| 67 | return false; |
| 68 | } |
| 69 | // Keys are equal - use ID for ordering |
| 70 | return a.unique_id < b.unique_id; |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | using TreeType = RedBlackTree<ValueWithId, PairCompareWithId, Allocator>; |
| 75 | TreeType mTree; |