How to efficiently wrap the index of a fixed-size circular buffer

前端 未结 6 1031
迷失自我
迷失自我 2021-01-03 04:50

I have a fixed size circular buffer (implemented as an array): upon initialization, the buffer gets filled with the specified maximum number of elements which allows the use

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 05:09

    Ensure that the buffer is always a power of two long and mask out the top bits.

提交回复
热议问题