QtCore/qcache.h Source File
Go to the documentation of this file.
53 template <class
Key, class T>
57 inline Node() : keyPtr(0) {}
58 inline Node(T *
data,
int cost)
59 : keyPtr(0),
t(data),
c(cost),
p(0),
n(0) {}
60 const Key *keyPtr; T *
t;
int c; Node *
p,*
n;
67 inline void unlink(Node &
n) {
68 if (n.p) n.p->n = n.n;
69 if (n.n) n.n->p = n.p;
77 inline T *relink(
const Key &key) {
84 if (n.p) n.p->n = n.n;
85 if (n.n) n.n->p = n.p;
95 Q_DISABLE_COPY(QCache)
98 inline explicit QCache(
int maxCost = 100);
100 inline QT3_SUPPORT_CONSTRUCTOR QCache(
int maxCost,
int )
101 :
f(0), l(0), mx(maxCost), total(0) {}
106 void setMaxCost(
int m);
116 bool insert(
const Key &key, T *
object,
int cost = 1);
117 T *object(
const Key &key)
const;
119 T *operator[](
const Key &key)
const;
121 bool remove(
const Key &key);
122 T *take(
const Key &key);
128 inline QT3_SUPPORT T *find(
const Key &key)
const {
return object(key); }
133 template <
class Key,
class T>
135 :
f(0), l(0), unused(0), mx(amaxCost), total(0) {}
137 template <
class Key,
class T>
139 {
while (
f) {
delete f->t;
f =
f->n; }
140 hash.clear(); l = 0; total = 0; }
142 template <
class Key,
class T>
144 { mx = m; trim(mx); }
146 template <
class Key,
class T>
150 template <
class Key,
class T>
152 {
return object(key); }
154 template <
class Key,
class T>
166 template <
class Key,
class T>
180 template <
class Key,
class T>
189 Node sn(aobject, acost);
193 n->keyPtr = &i.
key();
201 template <
class Key,
class T>
205 while (n && total > m) {
bool remove(const Key &key)
GLsizei GLsizei GLuint * obj
iterator find(const Key &key)
#define QT_BEGIN_NAMESPACE
int remove(const Key &key)
GLsizei GLsizei GLenum GLenum const GLvoid * data
const T value(const Key &key) const
bool insert(const Key &key, T *object, int cost=1)
bool contains(const Key &key) const
QList< Key > keys() const
T * object(const Key &key) const
const_iterator constEnd() const
iterator insert(const Key &key, const T &value)
bool contains(const Key &key) const
const Key key(const T &value) const
T * operator[](const Key &key) const
QList< Key > keys() const