[Development] QList
Lars Knoll
lars.knoll at qt.io
Tue Mar 21 08:37:08 CET 2017
Yes, as Thiago nicely points out there is a long history. But using QList as the name for something that we’d nowadays would call an array for Qt 4.0 is something that was indeed somewhat inspired by Java. We were looking a lot at the APIs provided in other languages (Java being the closest one to C++), as we weren’t always happy with what the C++ standard provided.
But I’d propose we don’t dig through the past too much, the decisions done then are nothing we can change anymore ;-)
Cheers,
Lars
> On 21 Mar 2017, at 04:57, Thiago Macieira <thiago.macieira at intel.com> wrote:
>
> Em segunda-feira, 20 de março de 2017, às 17:45:53 PDT, Kevin Kofler escreveu:
>> This assumption was already not true with Java 1.2, released December 8,
>> 1998. That release introduced java.util.List as a generic interface to ANY
>> list, including ArrayList. QList was introduced with Qt 4, released June 28,
>> 2005. So it is unfair to blame Qt for not following the obsolete
>> terminology you mention.
>
> You're forgetting Qt before 4.0. The current QList was introduced with Qt 4,
> but previous versions had QList too.
>
> I can't find the exact release date for 1.0, but it happened some time after
> 20-May-1995 (0.90) .
>
> Qt 1.x still supported compilers without template support (they were common in
> the early to mid 90s). If you had templates, then QList was a #define to
> QListT, which derived from QGList ("g" for generic), which was a doubly-linked
> list of pointers to the item in question. It had virtuals too. That is
> actually very similar to java.util.List...
>
> Qt 1.x also had a QVector (again, also provided as macro), deriving from
> QGVector, which was a pointer vector.
>
> Confusingly, what we now call "vector" was implemented by QArray, which
> derived from QGArray. QGArray managed only the byte-level array and QArray did
> the necessary casting to the element type, as well as multiplications and
> divisions by the element size. Unlike QList and QVector, QArray was reference-
> counted.
>
> QByteArray was typedef'ed to QArray<char>. QString derived from QByteArray
> but still operated on arbitrary encoding. QBitArray derived from QByteArray.
> There were also QStrList and QStrVec, which respectively derived from
> QList<char> and QVector<char>.
>
> Qt 2.0 was released on 25-May-1999. Aside from removing support for compilers
> that didn't support templates, QList, QVector and QArray remained the same. It
> introduced QValueList, a doubly-linked list of values (not pointers). Like
> QArray, it was reference-counted. QString was converted to UTF-16 and the old
> Qt 1 QString became QCString (still deriving from QByteArray). Because of the
> conversion, QStrList and QStrVec no longer worked with QString, so QStringList
> was introduced, a specialisation of QValueList<QString>.
>
> Qt 3.0 was released 11-Oct-2001. Qt 2's QList and QVector were renamed to
> QPtrList and QPtrVector, while QArray became QMemArray. All three headers had
> a "compat" macro that would #define the old names, to aid in porting from Qt 2.
> It expanded on Qt 2's QValueList and added QValueVector, with our current
> understanding of what a vector is. Like QValueList, it was reference-counted.
>
> Most of us still remember, Qt 4.0, which was packaged 24-June-2005 (date of
> the files inside the tarball). There was even a dance about it...
>
> Qt 3's QPtrList, QPtrVector (that is, Qt 1's QList and QVector) as well as
> QValueList and QValueVector became Q3PtrList, Q3PtrVector, Q3ValueList and
> Q3ValueVector. A new implementation was provided for QList, QVector and
> QByteArray, in the forms that we have today. QCString became Q3CString,
> deriving from Q3MemArray, deriving from Q3GArray. QBitArray moved to having a
> QByteArray member instead of deriving from it.
>
> Qt 5 dropped the Qt 1 code and introduced QArrayData, QTypedArrayData,
> QArrayDataPointer and QArrayDataOps, but time ran out before we could properly
> make use of them. QADP and QADO are unused in the main version; I'm using them
> in my branch in a class called QGenericArray (a base class of QVector).
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
More information about the Development
mailing list