[Development] QList for Qt 6
annulen at yandex.ru
Wed May 22 20:21:50 CEST 2019
22.05.2019, 21:19, "Giuseppe D'Angelo" <giuseppe.dangelo at kdab.com>:
> Il 22/05/19 20:14, Konstantin Tokarev ha scritto:
>>>> FWIW, std::deque is implemented as a peculiar data strucutre which is not really contiguous, and it may perform worse than QList in certain cases
>>> , as usual.
>> "As opposed to std::vector, the elements of a deque are not stored contiguously: typical implementations use a sequence of individually allocated fixed-size arrays, with additional bookkeeping, which means indexed access to deque must perform two pointer dereferences, compared to vector's indexed access which performs only one."
> Sure, but the question was about usage of a std::deque vs QList for fast
> prepending behavior, not for indexed access. Sticking to the same
> reference, it _also_ points out that appending at either extremity of
> std::deque is O(1) (vs. O(n) for QList). So, again, .
Well, I didn't mean that _prepend_ operation may be slower for deque than for QList. It just can be that the same container needs both prepending and indexed access, and QList (or similar contiguous container with reserved prepend space) can be more benefiicial in total.
More information about the Development