Some case inverting tristate buffer can be achieved by just keeping an inverter at output of tristate buffer. A switch in digital circuit can be achieved by isolating a signal path in a circuit. This switch can attain three logical states 0, 1 and ‘Z’. The logical state 0 and 1 are possible when the switch is CLOSE. The logical value ‘Z’ or high impedance is attained when switch is OPEN. So when switch is open the input to tristate buffer is isolated from the circuit and output can be driven by some other logical path on a shared connection/bus.
RTL code for tristatebuffer. Tri-