[Qt-interest] structure similar to QMap or QHash

Paul Colby qt at colby.id.au
Thu Oct 1 11:40:36 CEST 2009


If by "similar to QMap or QHash" you mean that you want to be able to
perform a key-based lookup, then why not use both a QHash (or QMap)
*and* a QList together.

For example, when you insert a key-value pair into the QHash, you can
append the same key to the QList.  Alternatively, when you insert the
value into the QList, you can also insert item's QList index into the
QHash under your desired key.  Which way is better would depend on why
you want both key-based and index-based access.

Of course, if you don't need key-based access, then simply use QList
(or QVector) as Ulf-Alexander v. Ceumern-Lindenstjerna suggested.

Feel free to elaborate on how you want to access the items, and maybe
we can help further :)

paul.

On Thu, Oct 1, 2009 at 6:39 PM, SALOMEHER at terra.es <SALOMEHER at terra.es> wrote:
> Hi, i need a structure similar to QMap or QHash, with QMap, the items are
> always sorted by key and with QHash, the items are arbitrarily ordered. I
> need a structure that supports the order of insertion.
> Any suggestions?
> Regards.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

--
http://colby.id.au



More information about the Qt-interest-old mailing list