c++ circular arrays

Discussion in 'Computer Science & Culture' started by gram1234, Mar 23, 2003.

Thread Status:
Not open for further replies.
  1. gram1234 Registered Member

    Messages:
    18
    What is a circular array and what are they used for mainly.Are they something that is user defined ,and if so,how?
    Thanks
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. AntonK Technomage Registered Senior Member

    Messages:
    1,083
    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
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. river-wind Valued Senior Member

    Messages:
    2,671
    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.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Rick Valued Senior Member

    Messages:
    3,336
    Hi,

    Have you worked with circular linked lists?

    curious...
    thanks.

    bye!
     
Thread Status:
Not open for further replies.

Share This Page