|
|
|
|
|
by orlp
1503 days ago
|
|
This breaks when your indices wrap around the integer limit. I'm not saying this can't be worked around but you end up with something much more complicated than just head==tail. It's a memory/runtime trade-off that I think is worth wasting one slot for. |
|
Modular arithmetic makes it work. Try a few examples close to UINT_MAX if you want to convince yourself.