[C++-SIG] How to use CXX...
Paul F. Dubois
dubois1 at llnl.gov
Tue May 23 03:21:11 CEST 2000
It is clear that a Python sequence type is a random access container. The
class Sequence in CXX is too. If you want to wrap a class that is not a
random access container, then it isn't a Sequence. You can invent a new
class for it that is a child of Object in the same way that Sequence is,
with whatever access rules you think are appropriate, but if your can't do
x[i] in reasonable time it is simply deceptive to have such an operator.
One model that may work is the Eiffel LIST; in Eiffel, most containers have
a cursor as part of their state. The cursor can be moved forward, placed at
the start, tested as whether it is off the end, etc. The access is then
x.item (which would be x.item() in C++) to get the value under the cursor.
More information about the Cplusplus-sig