I am manipulating many instances of the same data structure which can have one of four states. Currently I implement the states using True/False pairs:
(True, True)
(True, False)
(False, True)
(False, False)
With those data-structures I repeatedly apply two functions f, g where
g((True, True)) = (True, False)
g((True, False)) = (True, True)
g((False, True)) = (False, False)
g((False, False)) = (False, True)
and
f((True, True)) = (False, False)
f((True, False)) = (False, True)
f((False, True)) = (True, False)
f((False, False)) = (True, True)
Can I improve upon this data structure for those two functions? (I want to optimise for speed.)
Use an integer in the range of 0..3 and implement the state transitions with bit arithmetic (
gxors with 1;fxors with 3).