0

I want help regarding how to move data from one row to the next erasing the first row data subsequently.

I have 20 rows and my problem is to move data coming from the server from 1 row to the next, simultaneously deleting the first row data and moving the data further.

For example:- At first 20 rows are filled from 1st row to 20 row, then in the next attempt the log coming from the server has to be deleted from the first row and we have to display data from 2 to 21 ,next 3 to 22 and so on.

I have taken the vector and put the data as a string into the vector and now i have to move data from one row to next with the help of vectors in c++ only, while deleting the 1st row data and moving it forward like first filling 1 to 20 rows with 1 to 20 logs, then 1st row data is deleted and print 2 to 21 logs.

Please help if anyone has some idea.

Thanks.

tdesai
  • 1
  • 7

1 Answers1

1

What you've described is called a "circular buffer" or "ring buffer." And you don't need to implement it yourself, because Boost already has it: http://www.boost.org/doc/libs/release/doc/html/circular_buffer.html

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • Sir, is there any other way other then Circular buffer ?? – tdesai Jan 02 '15 at 08:35
  • @tdesai: what you've described *is* a circular buffer. To ask if there is another way, well, is there another fruit which is an apple other than an apple? – John Zwinck Jan 02 '15 at 08:37
  • By other way i mean with the use of vectors to move data from one row to another, while deleting the first row data and moving other data as it is coming. @John – tdesai Jan 02 '15 at 08:50
  • You could, but it would not be as efficient. I'm not sure why you're asking this? – John Zwinck Jan 02 '15 at 08:52
  • Sir, what i want is just put the erased data or log from the top of the row to stay in the vector, and just move data as an when coming from the server upto 1000 logs are completed. – tdesai Jan 02 '15 at 09:02