Make cpp code generator deterministic avoiding use of sets

Change-Id: I70dabcbaea573aa6c6980c995b46c90cbc9e1e95