Lazy reversal of a doubly linked list (source code)

= Lazy reversal of a doubly linked list

Keep the physical <doubly linked list> unchanged and represent the logical <sequence> in either forward or backward order according to a <Boolean> flag. Toggling the flag reverses the logical contents in constant <time complexity>. Endpoint insertion and indexed access must interpret their positions using the flag, and the <abstraction function> explicitly accounts for this choice.