[Development] QList for Qt 6

Shawn Rutledge Shawn.Rutledge at qt.io
Thu May 23 11:14:00 CEST 2019



> On 23 May 2019, at 07:51, Konstantin Shegunov <kshegunov at gmail.com> wrote:
> 
> On Thu, May 23, 2019 at 8:12 AM Mutz, Marc via Development <development at qt-project.org> wrote:
> On 2019-05-22 22:38, Konstantin Shegunov wrote:
> > What about a rather smart (in terms of storage) circular buffer; a
> > vector. Then the push, pop, enqueue and dequeue would be amortized
> > O(1)?
> 
> You mean like QCircularBuffer?
> 
> Yes, exactly like, though it'd need to regrow automatically; and on regrow it may need to normalize the order of elements (hence the "amortized”).

When should it regrow?  It’s part of the definition that it overwrites the oldest elements when you try to insert too much data.

I’m a big fan of the concept, have actually need one of these several times, and would like to see it moved to qtbase and made public, provided that the implementation is efficient and the API is maintainable (including for small numbers of small elements).  But we have several of them.  The so-called QRingBuffer is a different beast, and I am dubious that it’s the right solution even in its own use cases, let alone for general use.  IMO we should try to use a proper ring buffer/circular buffer template container to replace as many of these ring-buffer-like things as possible (there are really several of them).  QPODVector<qreal,10> velocityBuffer in the flickable implementation is a prime candidate to get replaced, for example (and in other cases where we are smoothing the velocity of something by keeping a running average).  Could we even agree that fixed-size (with size as a template parameter) is good enough?



More information about the Development mailing list