⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qintcache.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
字号:
'\" t.TH QIntCache 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQIntCache \- Template class that provides a cache based on long keys.SH SYNOPSIS\fC#include <qintcache.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQIntCache\fR ( int maxCost = 100, int size = 17 )".br.ti -1c.BI "\fB~QIntCache\fR ()".br.ti -1c.BI "int \fBmaxCost\fR () const".br.ti -1c.BI "int \fBtotalCost\fR () const".br.ti -1c.BI "void \fBsetMaxCost\fR ( int m )".br.ti -1c.BI "virtual uint \fBcount\fR () const".br.ti -1c.BI "uint \fBsize\fR () const".br.ti -1c.BI "bool \fBisEmpty\fR () const".br.ti -1c.BI "bool \fBinsert\fR ( long k, const type * d, int c = 1, int p = 0 )".br.ti -1c.BI "bool \fBremove\fR ( long k )".br.ti -1c.BI "type * \fBtake\fR ( long k )".br.ti -1c.BI "virtual void \fBclear\fR ()".br.ti -1c.BI "type * \fBfind\fR ( long k, bool ref = TRUE ) const".br.ti -1c.BI "type * \fBoperator[]\fR ( long k ) const".br.ti -1c.BI "void \fBstatistics\fR () const".br.in -1c.SH DESCRIPTIONThe QIntCache class is a template class that provides a cache based on long keys..PPQIntCache is implemented as a template class. Define a template instance QIntCache<X> to create a cache that operates on pointers to X, or X*..PPA cache is a least recently used (LRU) list of cache items, accessed via \fClong\fR keys. Each cache item has a cost. The sum of item costs, totalCost(), will not exceed the maximum cache cost, maxCost(). If inserting a new item would cause the total cost to exceed the maximum cost, the least recently used items in the cache are removed..PPApart from insert(), by far the most important function is find() (which also exists as operator[]). This function looks up an item, returns it, and by default marks it as being the most recently used item..PPThere are also methods to remove() or take() an object from the cache. Calling setAutoDelete(TRUE) for a cache tells it to delete items that are removed. The default is to not delete items when they are removed (i.e. remove() and take() are equivalent)..PPWhen inserting an item into the cache, only the pointer is copied, not the item itself. This is called a shallow copy. It is possible to make the cache copy all of the item's data (known as a deep copy) when an item is inserted. insert() calls the virtual function QPtrCollection::newItem() for the item to be inserted. Inherit a dictionary and reimplement newItem() if you want deep copies..PPWhen removing a cache item, the item will be automatically deleted if auto-deletion is enabled..PPThere is a QIntCacheIterator which may be used to traverse the items in the cache in arbitrary order..PPSee also QIntCacheIterator, QCache, QAsciiCache, Collection Classes, and Non-GUI Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QIntCache::QIntCache ( int maxCost = 100, int size = 17 )"Constructs a cache whose contents will never have a total cost greater than \fImaxCost\fR and which is expected to contain less than \fIsize\fR items..PP\fIsize\fR is actually the size of an internal hash array; it's usually best to make it prime and at least 50% bigger than the largest expected number of items in the cache..PPEach inserted item is associated with a cost. When inserting a new item, if the total cost of all items in the cache will exceed \fImaxCost\fR, the cache will start throwing out the older (least recently used) items until there is enough room for the new item to be inserted..SH "QIntCache::~QIntCache ()"Removes all items from the cache and then destroys the int cache. If auto-deletion is enabled the cache's items are deleted. All iterators that access this cache will be reset..SH "void QIntCache::clear ()\fC [virtual]\fR"Removes all items from the cache, and deletes them if auto-deletion has been enabled..PPAll cache iterators that operate this on cache are reset..PPSee also remove() and take()..SH "uint QIntCache::count () const\fC [virtual]\fR"Returns the number of items in the cache..PPSee also totalCost()..SH "type * QIntCache::find ( long k, bool ref = TRUE ) const"Returns the item associated with \fIk\fR, or 0 if the key does not exist in the cache. If \fIref\fR is TRUE (the default), the item is moved to the front of the least recently used list..PPIf there are two or more items with equal keys, the one that was inserted most recently is returned..SH "bool QIntCache::insert ( long k, const type * d, int c = 1, int p = 0 )"Inserts the item \fId\fR into the cache with key \fIk\fR and assigns it a cost of \fIc\fR (default 1). Returns TRUE if it succeeds; otherwise returns FALSE..PPThe cache's size is limited, and if the total cost is too high, QIntCache will remove old, least-used items until there is room for this new item..PPThe parameter \fIp\fR is internal and should be left at the default value (0)..PP\fBWarning:\fR If this function returns FALSE (for example, the cost \fC,\fR exceeds maxCost()), you must delete \fId\fR yourself. Additionally, be very careful about using \fId\fR after calling this function. Any other insertions into the cache, from anywhere in the application or within Qt itself, could cause the object to be discarded from the cache and the pointer to become invalid..SH "bool QIntCache::isEmpty () const"Returns TRUE if the cache is empty; otherwise returns FALSE..SH "int QIntCache::maxCost () const"Returns the maximum allowed total cost of the cache..PPSee also setMaxCost() and totalCost()..SH "type * QIntCache::operator[] ( long k ) const"Returns the item associated with \fIk\fR, or 0 if \fIk\fR does not exist in the cache, and moves the item to the front of the least recently used list..PPIf there are two or more items with equal keys, the one that was inserted most recently is returned..PPThis is the same as find( k, TRUE )..PPSee also find()..SH "bool QIntCache::remove ( long k )"Removes the item associated with \fIk\fR, and returns TRUE if the item was present in the cache; otherwise returns FALSE..PPThe item is deleted if auto-deletion has been enabled, i.e. if you have called setAutoDelete(TRUE)..PPIf there are two or more items with equal keys, the one that was inserted most recently is removed..PPAll iterators that refer to the removed item are set to point to the next item in the cache's traversal order..PPSee also take() and clear()..SH "void QIntCache::setMaxCost ( int m )"Sets the maximum allowed total cost of the cache to \fIm\fR. If the current total cost is greater than \fIm\fR, some items are removed immediately..PPSee also maxCost() and totalCost()..SH "uint QIntCache::size () const"Returns the size of the hash array used to implement the cache. This should be a bit larger than count() is likely to be..SH "void QIntCache::statistics () const"A debug-only utility function. Prints out cache usage, hit/miss, and distribution information using qDebug(). This function does nothing in the release library..SH "type * QIntCache::take ( long k )"Takes the item associated with \fIk\fR out of the cache without deleting it, and returns a pointer to the item taken out or 0 if the key does not exist in the cache..PPIf there are two or more items with equal keys, the one that was inserted most recently is taken..PPAll iterators that refer to the taken item are set to point to the next item in the cache's traversal order..PPSee also remove() and clear()..SH "int QIntCache::totalCost () const"Returns the total cost of the items in the cache. This is an integer in the range 0 to maxCost()..PPSee also setMaxCost()..SH "SEE ALSO".BR http://doc.trolltech.com/qintcache.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qintcache.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -