> I think you've gotten the terminology confused; -=, |= et al are
> non-destructive operations (ie they copy the data during operation), while
> m_delete() and `[]=() are destructive operations (ie no copying of data is
> performed).
>
Thanks for clearing it up. Yes, I was misunderstanding the effects of the terms
used.
> The possible downsides with using indexing is that you lose the "multi"
> of multiset, and that it is a destructive operation so you need to know
> that the multiset isn't in use for some other purpose.
In this case I was using the multiset as a 'single entry per index only', so
the ids[ identifier ] = 1/0 should work just fine for me. Instead of a multiset
which sets a specific index to 1 or 0, I could use a mapping and the same
construction, using m_delete instead of the setting to 0. Would there be a
difference in impact?
As for the being in use for some other purpose; is your warning about something
being less efficient if that were to happen, or about something possibly going
"buggy"?
The only race condition I can think of for
if (!has_value(some_array, identifier)) some_array += ({ identifier });
would be two threads both adding the identifier, because there might have been a
thread-switch between the moments of executing the has_value() and += .
> (up until a few minutes ago that is, since I've added an optimization of this
case to Pike 7.8).
Hehehehehehe. Way to go Grubba! :-)
Regards,
Arjan
|