1. A device comprising: an electrode; an alloy electrode; and an active region sandwiched between the electrode and the alloy electrode, the alloy electrode forms dopants in a sub-region of the active region adjacent to the alloy electrode such that the dopant can be selectively positioned within the active region to control the flow of charge carriers between the electrode and the alloy electrode, the active region comprising: a primary active layer comprising a material for transporting the dopant that controls the flow of charge carriers through the device; and a secondary active layer comprising the sub-region and providing one of a source and a sink of the dopants for the primary active region, wherein the secondary active layer comprises the material of the primary active layer that has reacted with the alloy electrode.