-
Notifications
You must be signed in to change notification settings - Fork 161
Description
Most uses of Gambit's historical bespoke container classes have been replaced by and/or reimplemented with their modern STL equivalents.
One (partial) exception to this is Gambit::List
. This class has been reimplemented so that internally it is just a std::list
, and can be used isomorphically with a std::list
. The class continues to exist for one reason: it also offers a subscript operator[]
, which provides a convenience for accessing elements of the list by an integer index. (For historical reasons, note this index starts with 1 for the first element.)
This continues to exist because while many users of the list have been re-written to use iterators, the range-notation for-loop, and so on, there remain a few places where removing the access by index cannot be eliminated by trivial code substitution. In some cases, this is mostly harmless; in a few cases, this does result in loops that should be linear becoming effectively quadratic.
(For those wondering how this came to be: The original Gambit::List
implementation had an internal cacheing feature that in effect implemented a crude iterator facility, and so accessing a list sequentially by index meant the access were effectively constant-time rather than linear time.)
The various uses of Gambit::List
will have different degrees of complication to replace. Some will require somewhat more global changes (e.g. the return values of Nash computational algorithms) requiring all to be changed at once, but mostly the individual changes will be trivial. A few (such as uses in enumpoly
) will require a bit more careful re-writing of some loops.
For each individual change it will be a good idea to ensure that the test suite covers adequately the affected code.