Wikipedia has a reasonable explanation of the basic algorithm:
http://en.wikipedia.org/wiki/Cheneys_algorithm
It probably gets more complicated if you try to share it with a non-copying collector, but the basic algorithm is very straightforward to implement.