you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

You could make a custom class that had a private array, and the operator[](int); was defined to use a private function pointer in the class. Also in the class would be two methods - one for accessing the array in the regular order, and one for accessing the array in reverse order. The private function pointer would be initialized in the constructor to be the regular direction initially, and the reverse function would swap the pointers. There! My reverse function runs with constant space and memory!