gram1234
03-23-03, 04:51 PM
What is a circular array and what are they used for mainly.Are they something that is user defined ,and if so,how?
Thanks
Thanks
|
|
View Full Version : c++ circular arrays gram1234 03-23-03, 04:51 PM What is a circular array and what are they used for mainly.Are they something that is user defined ,and if so,how? Thanks AntonK 03-23-03, 07:05 PM If you are referring to what I believe you are referring to they are usually used for queues. If you store a queue as an array and u enqueue to the right end and dequeue from the left end then you would have to shift all the info every time UNLESS you just stored the index of the front and back then you could have it work circular. Let me know if i need to clarify more. Its hard without pictures sometimes. BTW, this isnt just C++ it works in just about any language with arrays. -AntonK river-wind 03-26-03, 09:06 AM IIRC a circular array is one where the begining and the end are connected. so it's less of an array and more of an indexed list where lastFieldIndex+1=firstFieldIndex. I have found them used in places where a recent history of items reterived is needed- Grab value x, put it into the circular array, in the next position (ie, you have to keep an up-to-date pointer at all time to the "current" position). The last y items (y=length of array-1) are a history of all x's grabbed. The "next" space in the array is actually the oldest historical reference of x, and is then the least likely to be needed, and can be over-written with the new value. Alot like a computer's Cache memory system. Rick 03-27-03, 11:53 AM Hi, Have you worked with circular linked lists? curious... thanks. bye! |