O(1) optimizations for flip()