saxbophone / arby

Arbitrary precision arithmetic in C++, even at compile-time
https://saxbophone.com/arby/
Mozilla Public License 2.0
8 stars 1 forks source link

codlili: remove array-index operator #58

Closed saxbophone closed 2 years ago

saxbophone commented 2 years ago

codlili is not a truly random-access type and gives the false impression that elements can be accessed in constant time with this operator (they can't, we have to walk up the list, it's O(n)).

I've scanned the source of arby and all our access of the digits stored as codlili indicates we're either:

Once reverse iterators are implemented in #56, iterating backwards becomes trivial. All of these except the last point can be addressed with minimal modifications to Arby, the last one will require slightly more work though, as we'll need to maintain both an iterator and index count separately in these loops.

Note: this is an important fix for efficiency, in some places we use [] to iterate backwards in a for-loop --the hidden actual complexity of this loop becomes n! as a result!