  We introduce the concept of directed loops in stochastic series expansion and
path integral quantum Monte Carlo methods. Using the detailed balance rules for
directed loops, we show that it is possible to smoothly connect generally
applicable simulation schemes (in which it is necessary to include
back-tracking processes in the loop construction) to more restricted loop
algorithms that can be constructed only for a limited range of Hamiltonians
(where back-tracking can be avoided). The "algorithmic discontinuities" between
general and special points (or regions) in parameter space can hence be
eliminated. As a specific example, we consider the anisotropic S=1/2 Heisenberg
antiferromagnet in an external magnetic field. We show that directed loop
simulations are very efficient for the full range of magnetic fields (zero to
the saturation point) and anisotropies. In particular for weak fields and
anisotropies, the autocorrelations are significantly reduced relative to those
of previous approaches. The back-tracking probability vanishes continuously as
the isotropic Heisenberg point is approached. For the XY-model, we show that
back-tracking can be avoided for all fields extending up to the saturation
field. The method is hence particularly efficient in this case. We use directed
loop simulations to study the magnetization process in the 2D Heisenberg model
at very low temperatures. For LxL lattices with L up to 64, we utilize the
step-structure in the magnetization curve to extract gaps between different
spin sectors. Finite-size scaling of the gaps gives an accurate estimate of the
transverse susceptibility in the thermodynamic limit: chi_perp = 0.0659 +-
0.0002.
