Hello
I have been programming stacks and queues, and wondering if it is possible to program a circular queue.
What problems could happen?
Steve
Printable View
Hello
I have been programming stacks and queues, and wondering if it is possible to program a circular queue.
What problems could happen?
Steve
circular queues are most useful if their size is constant, nearly constant or don't run over certain limit. If it becomes full you need to resize it, and thats about the only concern with it, a size of power of two is ideal because then you can use the bitwise and operator to wrap around head and tail (modulus is slow and shouldn't be used, alternatively you can use ifs)
Hypothetically, if I created a circular list in Managed C++ and then lost my last external pointer to the 'ring' (but the list was still intact in memory) would the GC try to collect back the memory at the end of the program or would the ring stay in RAM until system shutdown?
GCs detect rings and remove them if they're orphaned.
Cool!