FastLED 3.9.15
Loading...
Searching...
No Matches

◆ erase() [2/3]

template<typename Key, typename Value, typename Compare = less<Key>, typename Allocator = allocator_slab<char>>
iterator fl::MapRedBlackTree< Key, Value, Compare, Allocator >::erase ( const_iterator first,
const_iterator last )
inline

Definition at line 1305 of file rbtree.h.

1305 {
1306 // Handle empty range case
1307 if (first == last) {
1308 // Convert const_iterator to iterator for empty range
1309 // We need to find the same position as an iterator
1310 if (first == mTree.cend()) {
1311 return mTree.end();
1312 }
1313 // For non-end iterator, find by constructing the full value_type for search
1314 return mTree.find(value_type(first->first, Value()));
1315 }
1316
1317 // Erase elements one by one from first to last
1318 // Use an iterator to track position since erase returns iterator
1319 iterator current = mTree.erase(first); // Erase first element and get iterator to next
1320
1321 // Continue erasing while we haven't reached last
1322 // We need to compare with last, but current is iterator and last is const_iterator
1323 // This works because iterator can be compared with const_iterator
1324 while (current != last) {
1325 current = mTree.erase(current);
1326 }
1327
1328 // Return iterator following the last removed element
1329 return current;
1330 }
typename TreeType::iterator iterator
Definition rbtree.h:1042
fl::pair< Key, Value > value_type
Definition rbtree.h:1002