Wrap the injured part in elastic bandaging or a similar material. If possible, raise the injured part above the level of your heart. Compression and elevation both help prevent swelling and may speed healing. It may not be practical to do all of these things, but the more you can do, the better. After 2 or 3 days, as swelling subsides, you may find it helpful to use a heating pad or warm water instead of ice.
Warmth reduces stiffness and promotes healing by increasing blood flow to the injured part.
But don't use heat in the first couple of days, because at that stage it promotes swelling. Steps to relieve pain and swelling are only half of treatment. The other half is activity. For example, if you have a sprained ankle, you may be able to work on range of motion in the first day or two by gently tracing letters with your big toe. Once your range of motion is fairly good, you can start doing gentle stretching and strengthening exercises.