Erase without invalidating iterator
Sign up to join this community After I didn't find any other solution, I ended up with a sequential workaround which will delete all records by time.And you may add some authorization because not everybody should be able to delete all records.So, the bad news is that a concurrent erase operation can deallocate the item you are traversing through and you’ll get garbage or an access violation exception.However, the good news is that beside erase() no other concurrent operation can deallocate already published address in TBB =2.2.//In your // p Limit is the (max) number of elements // which shall be deleted in each index // before the next transaction is created void My Contract::dtseq(uint64_t p Limit, uint128_t p Last Id) You can surely optimize by optimizing the loop logic or profit from parallel execution (when it is released).Also error messages and asserts should be included.
Hi, I've checked out various documentation for multimap but can't find anywhere it explicitly stated that insert() invalidates multimap iterators.I am using from which I want to delete all records.The user has the possibility to define how much elements shall be deleted per index per transaction. This gives the possibillity to test Index1; // same for test Index2 ...There's something that seems to be doing that (there's a lot of code so isn't definitely the mm calls at fault).-- Nick Keighley Ok so the iterator isn't invalid, but back to my pseudo code:- Data Item:: Multi Map::const_iterator iter = data Items.lower_bound(parameter Reference); Data Item:: Multi Map::const_iterator end = data Items.upper_bound(parameter Reference); while (iter !
Search for erase without invalidating iterator:
The standard says about associative containers [23.1.2/8]: The insert members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements. Ok so the iterator isn't invalid, but back to my pseudo code:- Data Item:: Multi Map::const_iterator iter = data Items.lower_bound(parameter Reference); Data Item:: Multi Map::const_iterator end = data Items.upper_bound(parameter Reference); while (iter !