Boost logo

Boost Users :

Subject: Re: [Boost-users] [circular_buffer] About overwriting elements
From: Jan Gaspar (jano_gaspar_at_[hidden])
Date: 2010-04-16 11:28:39


Hi Daniele, The circular_buffer behaves like a sliding window - which is what you don't want apparently. If you want the behaviour you described have a look at array_one() and array_two() methods. With regards, Jan ----- Original Message ---- From: Daniele Barzotti <daniele.barzotti_at_[hidden]> To: boost-users_at_[hidden] Sent: Fri, 16 April, 2010 15:31:31 Subject: [Boost-users] [circular_buffer] About overwriting elements Hi, in the introductory example I see this: int a = cb[0]; // a == 1 int b = cb[1]; // b == 2 int c = cb[2]; // c == 3 // The buffer is full now, pushing subsequent // elements will overwrite the front-most elements. cb.push_back(4); // Overwrite 1 with 4. cb.push_back(5); // Overwrite 2 with 5. // The buffer now contains 3, 4 and 5. a = cb[0]; // a == 3 b = cb[1]; // b == 4 c = cb[2]; // c == 5 and I would ask why the 4 and 5 are in the 2nd and 3th position instead of 1st and 2nd respectively. I thought that it worked in the following way: 1 2 3 1 2 3 1 2 3 [A][B][C] -> push_back(D) -> [D][B][C] -> push_back(E) -> [D][E][C] I need a circular buffer for buffering network data and I need that the old data is replaced but doesn't change its position.. Thanks, Daniele. _______________________________________________ Boost-users mailing list Boost-users_at_[hidden] http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net