You can also use this method when the wind is blowing off the dock and you're trying to get in, or you want to come in side-to into a tight space. Tie a line to a midship cleat, bring the bow to the dock at an angle, and either throw the line to someone onshore or have a crewmember step onto the dock from the bow. The line gets made fast to the dock aft of the cleat to which the line is tied. Put the engine in forward and swing the wheel away from the dock. The line will prevent forward motion and the stern will swing in.
Warping can also help you pivot around a piling and back into a slip if the current or wind is against you. Bring the side of the boat up against an outer piling. Tie one end of a line to a midship cleat, loop it around the piling, take up as much slack as possible, and tie the line back to the same cleat. The boat is now attached to the piling, which becomes your pivot point. Put the engine in reverse, turn the wheel toward the piling, and the stern will swing into the slip. Simple geometry.
The next time you get stuck in a tight docking situation, remember what your line, your cleats, and a little warped thinking can do.