[Development] QList

Thiago Macieira thiago.macieira at intel.com
Tue Mar 21 04:57:25 CET 2017


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




More information about the Development mailing list