May 23, 2000
1:21 a.m.
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.