jgraley / inferno-cpp2v

2 stars 0 forks source link

StandardAgent Collection algo detached iterator #167

Closed jgraley closed 3 years ago

jgraley commented 3 years ago

Following on from #165. As seen in 8110b6cfe8648c4420237a6d3376c4b25bbea724 under CHECK_ITERATOR_IN_CONTAINER in StandardAgent::DecidedQueryCollection() the iterator xit does not reference anything in xremaining and I will call that detached (it probably references something in x_decision or old_decision).

This could be remedied by:

  1. Put xremaining under shared_ptr and swap around the copies until we're copying just before the erase (i.e. copy-on-write behaviour, where erase() is the write)
  2. Make that copy a kind of Clone() operation, and give it the ability to carry iterators forward, i.e. reattach to the copy
  3. This would need to be implemented differently for each underlying container type:
    • list: end()-1 after push_back(value)
    • set: find(value) after insert(value) due uniqueness
    • multiset: some combination of the above?

However, I don't want to do any of that. Wider concerns seem to suggest it's time to do Collection decisions differently:

Note that while it feels bad to put this set into decisions, the size of the set depends only on pattern: it's always <= the number of non-star children in the collection in the pattern. Also, this strategy is the one that will eventually be used by the CSP for collection multiplicities.

jgraley commented 3 years ago

Regarding the new SubCollectionRange class:

SubContainerRangeWithExclusions could support other values for begin/end for example to avoid the need for exclusions for things at back or front - but I don't propose to use this. We do need (at least one of) them if we're going to drop the container pointer from Range, though.

jgraley commented 3 years ago

SubCollection should now fall out of use: delete it - see #231 Keeping around for replace, but removed elts for #231