Chapter 1: Hybrid Desktop/Internet ApplicationsWith a implement of a weather app to introduce it.
within it,I see a template class “QCache”.
In fact it use the qHash to store data and afford quick search. In the Qt4.7.2's doc It says:
The advantage of using QCache over some other key-based data structure (such as QMap or QHash) is that QCache automatically takes ownership of the objects that are inserted into the cache and deletes them to make room for new objects, if necessary. When inserting an object into the cache, you can specify a cost, which should bear some approximate relationship to the amount of memory taken by the object. When the sum of all objects' costs (totalCost()) exceeds the cache's limit (maxCost()), QCache starts deleting objects in the cache to keep under the limit, starting with less recently accessed objects.