Maybe you should answer to this SO question http://stackoverflow.com/questions/4151320/efficient-circular-buffer