DLList<Type T> is weird. If I want to access the n-th item, I can't use the [] operator because its not implemented (scalar for an example):
| Code: |
DLList<scalar> myDynamic; myDynamic.append(1); myDynamic.append(2); myDynamic.append(3); ...
|
If i do this for the 2nd item:
| Code: |
Info << myDynamic[2] << endl;
|
it breaks....
so I need to go like this for the n-th item:
| Code: |
DLList<scalar>::const_iterator myIt = myDynamic.begin() for (label i = 0; i < n; i++,++myIt); Info << *myIt << endl;
|
This works and will write out the n-th element on the screen. This is inherent to the linked lists, I know, but would it be a good thing if a method [] is added that does this thing? It would reduce code duplication.