Is it possible to create DofMaps based on current DofMaps

Hello, I want to ask a question based on this post. I’m interested to implement what is suggested here:

The easiest idea I have is to just modify the dofs that are linked to the boundary cells. I do cell iterations and collect the dofs in each cell

dofmap()->cell_dofs

and if any dof is a slave dof, I want to replace it with the corresponding master dof.
Since the new dofmap is based on the old one, I try to create it based on the old one, but unfortunately I could not really modify the cell_dofs directly.

Regarding this topic, can I create new DofMaps based the structure of current DofMap and do some modifications? Does anyone have any suggestions?

Thanks in advance!