-
Notifications
You must be signed in to change notification settings - Fork 97
Description
What if...
References were pointers instead of UInt´s?
With UInts we can have simple vector as mappings IF the solver does not support deletions. However, if the solver supports deletions we need some mapping. This mapping could be a vector, which would grow a lot with lots of deletions; could be a linked list which is fast to delete but not fast to access; could be a Dict which is easy to delete but not so fast to access.
Given that we usually do a lot more additions than deletions, may we should not be much worried of the time it takes to delete, but with the time it takes to add.
My proposal goes as follows, instead of giving the user a unique UInt everytime a variable/constraint is added we could give a pointer to an Int that directly matches the solver´s index, the SolverInstance would also hold a list of those pointers. In case of adding a constraint there would be no need for a lookup to get the solver´s corresponding index. In case of a deletion we can set that pointer to a zero value and fix all the other pointers since the SolverInstance has a list of them, then the user´s reference are fixed.