03.09.2013, 12:10, "Mandeep Sandhu" <mandeepsandhu....@gmail.com>:
> Hi All,
>
> Sometime (almost 2 yrs!) back we had a discussion here about having a new 
> container type in Qt which would be like a QMap, except that it stored keys 
> in their insertion order. This was mostly inspired by a Python data-structure 
> - OrderedDict 
> (http://docs.python.org/library/collections.html#collections.OrderedDict).
>
> Recently, I had some free time on hand and so though of implementing it using 
> existing Qt containers. Here's the code for it:
> https://github.com/mandeepsandhu/qt-ordered-map
>
> It's not a core container in itself as it uses existing Qt containers for 
> most of the implementation (much like the Python implementation).
>
> For storing the data I use a QHash and for keeping the key (insertion) order, 
> I use a QLinkedList. The value stored in the hash, is actually a pair - of 
> the user provided value and a QLinkedList _iterator_ which points to the item 
> inserted in the linklist. This makes it quite easy and fast to delete items 
> from these 2 containers in constant time.
>
> The performance of this container is similar to QHash except when you want 
> all the values from it, as that requires first fetching the keys from the 
> linklist and then using that to fetch the values from the hash table.
>
> It provides a sub-set of QMap API, complete with const and non-const 
> iterators (you can use 'foreach' for iterating over all the values in their 
> insert order).
>
> In case you want to use such a container, please try it out and let me know 
> your feedback.

You need to use Boost.MultiIndex.


-- 
Regards,
Konstantin
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to