It's very-well-known tip for cyclic queue!
Here is pseudo code!
(Even if this is very -well-known and not difficult to think of, it's worth to remind.)
TYPE Q
item[SZ] // queue array
i // current index
...
FUNC addQ (q, item)
// This is Naive way.
item[q.i] = item
if (q.i >= SZ) than q.i = 0
// This is well-known way
item[q.i] = item
q.i &= SZ-1 // For this, SZ should be (2^n (n>0))'Domain > Software' 카테고리의 다른 글
| [Remind] To know thich dynamic linker is required for the executable file.. (0) | 2011.05.18 |
|---|---|
| [GNU] Issues of cross-compiling in GNU build system. (0) | 2011.04.21 |
| [SW] Questions to evaluate SW Engineer (0) | 2009.04.09 |
| [Prog] Using so-called 'context' data structure. (0) | 2008.01.10 |
| [Prog] Take care of errata when using float/double at all times! (0) | 2007.01.26 |