Optical switches and logic devices comprising microstructure-doped
nanocavity lasers are described. These switches and logic devices have
gain and thus can be cascaded and integrated in a network or system such
as for example on a chip. Exemplary switching elements switch the
intensity, wavelength, or direction of the output. Exemplary logic
devices include AND, OR, NAND, NOR, NOT, and XOR gates as well as
flip-flops. Microfluidic sorting and delivery as well as optical tweezing
and trapping may be employ to select and position a light emitter in an
nanooptical cavity to form the nanolaser.