FixedMap and FixedOrderedMultimap behave differently for erase #221

Open
opened 2020-09-30 11:21:08 +02:00 by gaisser · 1 comment
Owner

The behaviour of FixedMap and FixedOrderedMultimap is different in the ReturnValue_t erase(Iterator *iter) function. I suggest to make them behave the same in respect to the iterator.

At the moment the FixedMap can be completly erased by calling:

	for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++){
		map.erase(&it);
	}

The fixedOrderedMap on the other hand must be deleted with a while loop:

	while (it != map.end()) {
		map.erase(&it);
		it = map.begin();
	}
The behaviour of FixedMap and FixedOrderedMultimap is different in the ``` ReturnValue_t erase(Iterator *iter)``` function. I suggest to make them behave the same in respect to the iterator. At the moment the FixedMap can be completly erased by calling: ``` c++ for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++){ map.erase(&it); } ``` The fixedOrderedMap on the other hand must be deleted with a while loop: ``` c++ while (it != map.end()) { map.erase(&it); it = map.begin(); } ```
Author
Owner

In comparison a std::map is erased by:

    auto it = testMap.begin();
    while(it != testMap.end()){
    	it = testMap.erase(it);
    }
In comparison a std::map is erased by: ``` c++ auto it = testMap.begin(); while(it != testMap.end()){ it = testMap.erase(it); } ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fsfw/fsfw#221
No description provided.