qgcache.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 **
4 ** Implementation of QGCache and QGCacheIterator classes
5 **
6 ** Created : 950208
7 **
8 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9 **
10 ** This file is part of the tools module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech AS of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 ** information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #include "qgcache.h"
39 #include "qinternallist.h"
40 #include "qdict.h"
41 #include "qstring.h"
42 
43 
44 // NOT REVISED
45 /*!
46  \class QGCache qgcache.h
47 
48  \brief The QGCache class is an internal class for implementing QCache template classes.
49 
50  QGCache is a strictly internal class that acts as a base class for the
51  \link collection.html collection classes\endlink QCache and QIntCache.
52 */
53 
54 
55 /*****************************************************************************
56  QGCacheItem class (internal cache item)
57  *****************************************************************************/
58 
59 struct QCacheItem
60 {
61  QCacheItem( void *k, QCollection::Item d, int c, short p )
62  : priority(p), skipPriority(p), cost(c), key(k), data(d), node(0) {}
63  short priority;
64  short skipPriority;
65  int cost;
66  void *key;
69 };
70 
71 
72 /*****************************************************************************
73  QCList class (internal list of cache items)
74  *****************************************************************************/
75 
76 class QCList : private QInternalList<QCacheItem>
77 {
78 friend class QGCacheIterator;
79 friend class QCListIt;
80 public:
81  QCList() {}
82  ~QCList();
83 
84  void insert( QCacheItem * ); // insert according to priority
85  void insert( int, QCacheItem * );
86  void take( QCacheItem * );
87  void reference( QCacheItem * );
88 
89  void setAutoDelete( bool del ) { QCollection::setAutoDelete(del); }
90 
93 
98 
99 #if defined(DEBUG)
100  int inserts; // variables for statistics
103  int finds;
104  int hits;
105  int hitCosts;
106  int dumps;
108 #endif
109 };
110 
111 
113 {
114 #if defined(DEBUG)
115  ASSERT( count() == 0 );
116 #endif
117 }
118 
119 
121 {
122  QCacheItem *item = first();
123  while( item && item->skipPriority > ci->priority ) {
124  item->skipPriority--;
125  item = next();
126  }
127  if ( item )
129  else
130  append( ci );
131 #if defined(DEBUG)
132  ASSERT( ci->node == 0 );
133 #endif
134  ci->node = currentNode();
135 }
136 
137 inline void QCList::insert( int i, QCacheItem *ci )
138 {
140 #if defined(DEBUG)
141  ASSERT( ci->node == 0 );
142 #endif
143  ci->node = currentNode();
144 }
145 
146 
148 {
149  if ( ci ) {
150 #if defined(DEBUG)
151  ASSERT( ci->node != 0 );
152 #endif
153  takeNode( ci->node );
154  ci->node = 0;
155  }
156 }
157 
158 
159 inline void QCList::reference( QCacheItem *ci )
160 {
161 #if defined(DEBUG)
162  ASSERT( ci != 0 && ci->node != 0 );
163 #endif
164  ci->skipPriority = ci->priority;
165  relinkNode( ci->node ); // relink as first item
166 }
167 
168 
169 class QCListIt: public QInternalListIterator<QCacheItem>
170 {
171 public:
174 };
175 
176 
177 /*****************************************************************************
178  QCDict class (internal dictionary of cache items)
179  *****************************************************************************/
180 
181 //
182 // Since we need to decide if the dictionary should use an int or const
183 // char * key (the "bool trivial" argument in the constructor below)
184 // we cannot use the macro/template dict, but inherit directly from QGDict.
185 //
186 
187 class QCDict : public QGDict
188 {
189 public:
190  QCDict( uint size, uint kt, bool caseSensitive, bool copyKeys )
191  : QGDict( size, (KeyType)kt, caseSensitive, copyKeys ) {}
192 
194  { return (QCacheItem*)((QCDict*)this)->look_string(key, 0, 0); }
195  QCacheItem *find_ascii(const char *key) const
196  { return (QCacheItem*)((QCDict*)this)->look_ascii(key, 0, 0); }
197  QCacheItem *find_int(long key) const
198  { return (QCacheItem*)((QCDict*)this)->look_int(key, 0, 0); }
199 
201  { return (QCacheItem*)QGDict::take_string(key); }
202  QCacheItem *take_ascii(const char *key)
203  { return (QCacheItem*)QGDict::take_ascii(key); }
205  { return (QCacheItem*)QGDict::take_int(key); }
206 
207  bool insert_string( const QString &key, const QCacheItem *ci )
208  { return QGDict::look_string(key,(Item)ci,1)!=0;}
209  bool insert_ascii( const char *key, const QCacheItem *ci )
210  { return QGDict::look_ascii(key,(Item)ci,1)!=0;}
211  bool insert_int( long key, const QCacheItem *ci )
212  { return QGDict::look_int(key,(Item)ci,1)!=0;}
213 
214  bool remove_string( QCacheItem *item )
215  { return QGDict::remove_string(*((QString*)(item->key)),item); }
216  bool remove_ascii( QCacheItem *item )
217  { return QGDict::remove_ascii((const char *)item->key,item); }
218  bool remove_int( QCacheItem *item )
219  { return QGDict::remove_int((intptr_t)item->key,item);}
220 
222 };
223 
224 
225 /*****************************************************************************
226  QGDict member functions
227  *****************************************************************************/
228 
229 /*!
230  \internal
231  Constructs a cache.
232 */
233 
234 QGCache::QGCache( int maxCost, uint size, KeyType kt, bool caseSensitive,
235  bool copyKeys )
236 {
237  keytype = kt;
238  lruList = new QCList;
239  CHECK_PTR( lruList );
240  lruList->setAutoDelete( TRUE );
241  copyk = ((keytype == AsciiKey) && copyKeys);
242  dict = new QCDict( size, kt, caseSensitive, FALSE );
243  CHECK_PTR( dict );
244  mCost = maxCost;
245  tCost = 0;
246 #if defined(DEBUG)
247  lruList->inserts = 0;
248  lruList->insertCosts = 0;
249  lruList->insertMisses = 0;
250  lruList->finds = 0;
251  lruList->hits = 0;
252  lruList->hitCosts = 0;
253  lruList->dumps = 0;
254  lruList->dumpCosts = 0;
255 #endif
256 }
257 
258 /*!
259  \internal
260  Cannot copy a cache.
261 */
262 
264  : QCollection()
265 {
266 #if defined(CHECK_NULL)
267  qFatal( "QGCache::QGCache(QGCache &): Cannot copy a cache" );
268 #endif
269 }
270 
271 /*!
272  \internal
273  Removes all items from the cache and destroys it.
274 */
275 
277 {
278  clear(); // delete everything first
279  delete dict;
280  delete lruList;
281 }
282 
283 /*!
284  \internal
285  Cannot assign a cache.
286 */
287 
289 {
290 #if defined(CHECK_NULL)
291  qFatal( "QGCache::operator=: Cannot copy a cache" );
292 #endif
293  return *this; // satisfy the compiler
294 }
295 
296 
297 /*!
298  \fn uint QGCache::count() const
299  \internal
300  Returns the number of items in the cache.
301 */
302 
303 /*!
304  \fn uint QGCache::size() const
305  \internal
306  Returns the size of the hash array.
307 */
308 
309 /*!
310  \fn int QGCache::maxCost() const
311  \internal
312  Returns the maximum cache cost.
313 */
314 
315 /*!
316  \fn int QGCache::totalCost() const
317  \internal
318  Returns the total cache cost.
319 */
320 
321 /*!
322  \internal
323  Sets the maximum cache cost.
324 */
325 
327 {
328  if ( maxCost < tCost ) {
329  if ( !makeRoomFor(tCost - maxCost) ) // remove excess cost
330  return;
331  }
332  mCost = maxCost;
333 }
334 
335 
336 /*!
337  \internal
338  Inserts an item into the cache.
339 
340  \warning If this function returns FALSE, you must delete \a data
341  yourself. Additionally, be very careful about using \a data after
342  calling this function, as any other insertions into the cache, from
343  anywhere in the application, or within Qt itself, could cause the
344  data to be discarded from the cache, and the pointer to become
345  invalid.
346 */
347 
349  int cost, int priority)
350 {
351  if ( tCost + cost > mCost ) {
352  if ( !makeRoomFor(tCost + cost - mCost, priority) ) {
353 #if defined(DEBUG)
355 #endif
356  return FALSE;
357  }
358  }
359 #if defined(DEBUG)
360  ASSERT( keytype == StringKey );
361  lruList->inserts++;
362  lruList->insertCosts += cost;
363 #endif
364  if ( priority < -32768 )
365  priority = -32768;
366  else if ( priority > 32767 )
367  priority = 32677;
368  QCacheItem *ci = new QCacheItem( new QString(key), newItem(data),
369  cost, (short)priority );
370  CHECK_PTR( ci );
371  lruList->insert( 0, ci );
372  dict->insert_string( key, ci );
373  tCost += cost;
374  return TRUE;
375 }
376 
377 
378 /*! \internal */
379 
381  int cost, int priority)
382 {
383  if ( tCost + cost > mCost ) {
384  if ( !makeRoomFor(tCost + cost - mCost, priority) ) {
385 #if defined(DEBUG)
387 #endif
388  return FALSE;
389  }
390  }
391 #if defined(DEBUG)
392  ASSERT( keytype != StringKey );
393  lruList->inserts++;
394  lruList->insertCosts += cost;
395 #endif
396  if ( keytype == AsciiKey && copyk )
397  key = qstrdup( key );
398  if ( priority < -32768 )
399  priority = -32768;
400  else if ( priority > 32767 )
401  priority = 32677;
402  QCacheItem *ci = new QCacheItem( (void*)key, newItem(data), cost,
403  (short)priority );
404  CHECK_PTR( ci );
405  lruList->insert( 0, ci );
406  if ( keytype == AsciiKey )
407  dict->insert_ascii( key, ci );
408  else
409  dict->insert_int( (intptr_t)key, ci );
410  tCost += cost;
411  return TRUE;
412 }
413 
414 
415 /*!
416  \internal
417  Removes an item from the cache.
418 */
419 
421 {
422  Item d = take_string( key );
423  if ( d )
424  deleteItem( d );
425  return d != 0;
426 }
427 
428 
429 /*! \internal */
430 
431 bool QGCache::remove_other( const char *key )
432 {
433  Item d = take_other( key );
434  if ( d )
435  deleteItem( d );
436  return d != 0;
437 }
438 
439 
440 /*!
441  \internal
442  Takes an item out of the cache (no delete).
443 */
444 
446 {
447  QCacheItem *ci = dict->take_string( key ); // take from dict
448  Item d;
449  if ( ci ) {
450  d = ci->data;
451  tCost -= ci->cost;
452  lruList->take( ci ); // take from list
453  delete (QString*)ci->key;
454  delete ci;
455  } else {
456  d = 0;
457  }
458  return d;
459 }
460 
461 /*!
462  \internal
463  Takes an item out of the cache (no delete).
464 */
465 
467 {
468  QCacheItem *ci;
469  if ( keytype == AsciiKey )
470  ci = dict->take_ascii( key );
471  else
472  ci = dict->take_int( (intptr_t)key );
473  Item d;
474  if ( ci ) {
475  d = ci->data;
476  tCost -= ci->cost;
477  lruList->take( ci ); // take from list
478  if ( copyk )
479  delete [] (char *)ci->key;
480  delete ci;
481  } else {
482  d = 0;
483  }
484  return d;
485 }
486 
487 
488 /*!
489  \internal
490  Clears the cache.
491 */
492 
494 {
495  QCacheItem *ci;
496  while ( (ci = lruList->first()) ) {
497  switch ( keytype ) {
498  case StringKey:
499  dict->remove_string( ci );
500  delete (QString*)ci->key;
501  break;
502  case AsciiKey:
503  dict->remove_ascii( ci );
504  if ( copyk )
505  delete [] (char*)ci->key;
506  break;
507  case IntKey:
508  dict->remove_int( ci );
509  break;
510  case PtrKey: // unused
511  break;
512  }
513  deleteItem( ci->data ); // delete data
514  lruList->removeFirst(); // remove from list
515  }
516  tCost = 0;
517 }
518 
519 
520 /*!
521  \internal
522  Finds an item in the cache.
523 */
524 
526 {
527  QCacheItem *ci = dict->find_string( key );
528 #if defined(DEBUG)
529  lruList->finds++;
530 #endif
531  if ( ci ) {
532 #if defined(DEBUG)
533  lruList->hits++;
534  lruList->hitCosts += ci->cost;
535 #endif
536  if ( ref )
537  lruList->reference( ci );
538  return ci->data;
539  }
540  return 0;
541 }
542 
543 
544 /*!
545  \internal
546  Finds an item in the cache.
547 */
548 
549 QCollection::Item QGCache::find_other( const char *key, bool ref ) const
550 {
551  QCacheItem *ci = keytype == AsciiKey ? dict->find_ascii(key)
552  : dict->find_int((intptr_t)key);
553 #if defined(DEBUG)
554  lruList->finds++;
555 #endif
556  if ( ci ) {
557 #if defined(DEBUG)
558  lruList->hits++;
559  lruList->hitCosts += ci->cost;
560 #endif
561  if ( ref )
562  lruList->reference( ci );
563  return ci->data;
564  }
565  return 0;
566 }
567 
568 
569 /*!
570  \internal
571  Allocates cache space for one or more items.
572 */
573 
574 bool QGCache::makeRoomFor( int cost, int priority )
575 {
576  if ( cost > mCost ) // cannot make room for more
577  return FALSE; // than maximum cost
578  if ( priority == -1 )
579  priority = 32767;
580  register QCacheItem *ci = lruList->last();
581  int cntCost = 0;
582  int dumps = 0; // number of items to dump
583  while ( cntCost < cost && ci && ci->skipPriority <= priority ) {
584  cntCost += ci->cost;
585  ci = lruList->prev();
586  dumps++;
587  }
588  if ( cntCost < cost ) // can enough cost be dumped?
589  return FALSE; // no
590 #if defined(DEBUG)
591  ASSERT( dumps > 0 );
592 #endif
593  while ( dumps-- ) {
594  ci = lruList->last();
595 #if defined(DEBUG)
596  lruList->dumps++;
597  lruList->dumpCosts += ci->cost;
598 #endif
599  switch ( keytype ) {
600  case StringKey:
601  dict->remove_string( ci );
602  delete (QString*)ci->key;
603  break;
604  case AsciiKey:
605  dict->remove_ascii( ci );
606  if ( copyk )
607  delete [] (char *)ci->key;
608  break;
609  case IntKey:
610  dict->remove_int( ci );
611  break;
612  case PtrKey: // unused
613  break;
614  }
615  deleteItem( ci->data ); // delete data
616  lruList->removeLast(); // remove from list
617  }
618  tCost -= cntCost;
619  return TRUE;
620 }
621 
622 
623 /*!
624  \internal
625  Outputs debug statistics.
626 */
627 
629 {
630 #if defined(DEBUG)
631  QString line;
632  line.fill( '*', 80 );
633  qDebug( "%s",line.ascii() );
634  qDebug( "CACHE STATISTICS:" );
635  qDebug( "cache contains %d item%s, with a total cost of %d",
636  count(), count() != 1 ? "s" : "", tCost );
637  qDebug( "maximum cost is %d, cache is %d%% full.",
638  mCost, (200*tCost + mCost) / (mCost*2) );
639  qDebug( "find() has been called %d time%s",
640  lruList->finds, lruList->finds != 1 ? "s" : "" );
641  qDebug( "%d of these were hits, items found had a total cost of %d.",
643  qDebug( "%d item%s %s been inserted with a total cost of %d.",
644  lruList->inserts,lruList->inserts != 1 ? "s" : "",
645  lruList->inserts != 1 ? "have" : "has", lruList->insertCosts );
646  qDebug( "%d item%s %s too large or had too low priority to be inserted.",
647  lruList->insertMisses, lruList->insertMisses != 1 ? "s" : "",
648  lruList->insertMisses != 1 ? "were" : "was" );
649  qDebug( "%d item%s %s been thrown away with a total cost of %d.",
650  lruList->dumps, lruList->dumps != 1 ? "s" : "",
651  lruList->dumps != 1 ? "have" : "has", lruList->dumpCosts );
652  qDebug( "Statistics from internal dictionary class:" );
653  dict->statistics();
654  qDebug( "%s",line.ascii() );
655 #endif
656 }
657 
658 int QGCache::hits() const
659 {
660  return lruList->hits;
661 }
662 
663 int QGCache::misses() const
664 {
665  return lruList->finds - lruList->hits;
666 }
667 
668 
669 /*****************************************************************************
670  QGCacheIterator member functions
671  *****************************************************************************/
672 
673 /*!
674  \class QGCacheIterator qgcache.h
675 
676  \brief An internal class for implementing QCacheIterator and QIntCacheIterator.
677 
678  QGCacheIterator is a strictly internal class that does the heavy work for
679  QCacheIterator and QIntCacheIterator.
680 */
681 
682 /*!
683  \internal
684  Constructs an iterator that operates on the cache \e c.
685 */
686 
688 {
689  it = new QCListIt( c.lruList );
690 #if defined(DEBUG)
691  ASSERT( it != 0 );
692 #endif
693 }
694 
695 /*!
696  \internal
697  Constructs an iterator that operates on the same cache as \e ci.
698 */
699 
701 {
702  it = new QCListIt( ci.it );
703 #if defined(DEBUG)
704  ASSERT( it != 0 );
705 #endif
706 }
707 
708 /*!
709  \internal
710  Destroys the iterator.
711 */
712 
714 {
715  delete it;
716 }
717 
718 /*!
719  \internal
720  Assigns the iterator \e ci to this cache iterator.
721 */
722 
724 {
725  *it = *ci.it;
726  return *this;
727 }
728 
729 /*!
730  \internal
731  Returns the number of items in the cache.
732 */
733 
735 {
736  return it->count();
737 }
738 
739 /*!
740  \internal
741  Returns TRUE if the iterator points to the first item.
742 */
743 
745 {
746  return it->atFirst();
747 }
748 
749 /*!
750  \internal
751  Returns TRUE if the iterator points to the last item.
752 */
753 
755 {
756  return it->atLast();
757 }
758 
759 /*!
760  \internal
761  Sets the list iterator to point to the first item in the cache.
762 */
763 
765 {
766  QCacheItem *item = it->toFirst();
767  return item ? item->data : 0;
768 }
769 
770 /*!
771  \internal
772  Sets the list iterator to point to the last item in the cache.
773 */
774 
776 {
777  QCacheItem *item = it->toLast();
778  return item ? item->data : 0;
779 }
780 
781 /*!
782  \internal
783  Returns the current item.
784 */
785 
787 {
788  QCacheItem *item = it->current();
789  return item ? item->data : 0;
790 }
791 
792 /*!
793  \internal
794  Returns the key of the current item.
795 */
796 
798 {
799  QCacheItem *item = it->current();
800  return item ? *((QString*)item->key) : QString::null;
801 }
802 
803 /*!
804  \internal
805  Returns the key of the current item, as a \0-terminated C string.
806 */
807 
808 const char *QGCacheIterator::getKeyAscii() const
809 {
810  QCacheItem *item = it->current();
811  return item ? (const char *)item->key : 0;
812 }
813 
814 /*!
815  \internal
816  Returns the key of the current item, as a long.
817 */
818 
820 {
821  QCacheItem *item = it->current();
822  return item ? (intptr_t)item->key : 0;
823 }
824 
825 /*!
826  \internal
827  Moves to the next item (postfix).
828 */
829 
831 {
832  QCacheItem *item = it->operator()();
833  return item ? item->data : 0;
834 }
835 
836 /*!
837  \internal
838  Moves to the next item (prefix).
839 */
840 
842 {
843  QCacheItem *item = it->operator++();
844  return item ? item->data : 0;
845 }
846 
847 /*!
848  \internal
849  Moves \e jumps positions forward.
850 */
851 
853 {
854  QCacheItem *item = it->operator+=(jump);
855  return item ? item->data : 0;
856 }
857 
858 /*!
859  \internal
860  Moves to the previous item (prefix).
861 */
862 
864 {
865  QCacheItem *item = it->operator--();
866  return item ? item->data : 0;
867 }
868 
869 /*!
870  \internal
871  Moves \e jumps positions backward.
872 */
873 
875 {
876  QCacheItem *item = it->operator-=(jump);
877  return item ? item->data : 0;
878 }
bool remove_ascii(QCacheItem *item)
Definition: qgcache.cpp:216
void statistics() const
Definition: qgdict.cpp:930
bool insert_string(const QString &key, const QCacheItem *ci)
Definition: qgcache.cpp:207
intptr_t getKeyInt() const
Definition: qgcache.cpp:819
QCListIt(const QCListIt *p)
Definition: qgcache.cpp:173
QCacheItem * next()
Definition: qgcache.cpp:97
void qDebug(const char *msg,...)
Definition: qglobal.cpp:376
virtual Item newItem(Item)
bool insert_int(long key, const QCacheItem *ci)
Definition: qgcache.cpp:211
void insert(QCacheItem *)
Definition: qgcache.cpp:120
The QGCache class is an internal class for implementing QCache template classes.
Definition: qgcache.h:53
def dumps(spectra, indent=4)
Definition: persist.py:8
QCacheItem * first()
Definition: qgcache.cpp:94
void take(QCacheItem *)
Definition: qgcache.cpp:147
KeyType keytype
Definition: qgcache.h:91
int maxCost() const
Definition: qgcache.h:68
QCollection::Item operator-=(uint)
Definition: qgcache.cpp:874
type * first()
Definition: qinternallist.h:87
int hitCosts
Definition: qgcache.cpp:105
int dumps
Definition: qgcache.cpp:106
void reference(QCacheItem *)
Definition: qgcache.cpp:159
QCacheItem * find_string(const QString &key) const
Definition: qgcache.cpp:193
QCollection::Item find_string(const QString &key, bool ref=TRUE) const
Definition: qgcache.cpp:525
QGCacheIterator(const QGCache &)
Definition: qgcache.cpp:687
QGCacheIterator & operator=(const QGCacheIterator &)
Definition: qgcache.cpp:723
const bool FALSE
Definition: qglobal.h:370
QGCache(int maxCost, uint size, KeyType kt, bool caseSensitive, bool copyKeys)
Definition: qgcache.cpp:234
int insertCosts
Definition: qgcache.cpp:101
KeyType
Definition: qgcache.h:57
uint count() const
Definition: qgcache.h:66
bool makeRoomFor(int cost, int priority=-1)
Definition: qgcache.cpp:574
int inserts
Definition: qgcache.cpp:100
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
bool remove_string(QCacheItem *item)
Definition: qgcache.cpp:214
QCollection::Item take_string(const QString &key)
Definition: qgcache.cpp:445
~QCList()
Definition: qgcache.cpp:112
int insertMisses
Definition: qgcache.cpp:102
QCollection::Item look_int(long key, QCollection::Item, int)
Definition: qgdict.cpp:461
bool atFirst() const
Definition: qgcache.cpp:744
QGCache & operator=(const QGCache &)
Definition: qgcache.cpp:288
QCollection::Item toFirst()
Definition: qgcache.cpp:764
QCollection::Item look_ascii(const char *key, QCollection::Item, int)
Definition: qgdict.cpp:422
bool insert_ascii(const char *key, const QCacheItem *ci)
Definition: qgcache.cpp:209
~QGCache()
Definition: qgcache.cpp:276
QCList * lruList
Definition: qgcache.h:92
void fill(QChar c, int len=-1)
Definition: qstring.cpp:12865
int misses() const
Definition: qgcache.cpp:663
int hits() const
Definition: qgcache.cpp:658
void setMaxCost(int maxCost)
Definition: qgcache.cpp:326
QCacheItem * prev()
Definition: qgcache.cpp:96
QCacheItem(void *k, QCollection::Item d, int c, short p)
Definition: qgcache.cpp:61
bool insert_string(const QString &key, QCollection::Item, int cost, int priority)
Definition: qgcache.cpp:348
An internal class for implementing QCacheIterator and QIntCacheIterator.
Definition: qgcache.h:100
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool copyk
Definition: qgcache.h:96
bool remove_other(const char *key)
Definition: qgcache.cpp:431
QCollection::Item operator+=(uint)
Definition: qgcache.cpp:852
const char * ascii() const
Definition: qstring.cpp:14494
QCollection::Item operator++()
Definition: qgcache.cpp:841
def key(type, name=None)
Definition: graph.py:13
bool remove_string(const QString &key, QCollection::Item item=0)
Definition: qgdict.cpp:732
short priority
Definition: qgcache.cpp:63
void statistics() const
Definition: qgcache.cpp:628
type * prev()
Definition: qinternallist.h:90
void statistics()
Definition: qgcache.cpp:221
bool removeFirst()
Definition: qgcache.cpp:91
bool insert(uint i, const type *d)
Definition: qinternallist.h:58
QCollection::Item take_ascii(const char *key)
Definition: qgdict.cpp:804
QCacheItem * find_ascii(const char *key) const
Definition: qgcache.cpp:195
short skipPriority
Definition: qgcache.cpp:64
The QCollection class is the base class of all Qt collections.
Definition: qcollection.h:51
QCDict(uint size, uint kt, bool caseSensitive, bool copyKeys)
Definition: qgcache.cpp:190
QCollection::Item find_other(const char *key, bool ref=TRUE) const
Definition: qgcache.cpp:549
int cost
Definition: qgcache.cpp:65
bool remove_ascii(const char *key, QCollection::Item item=0)
Definition: qgdict.cpp:747
p
Definition: test.py:223
bool remove_string(const QString &key)
Definition: qgcache.cpp:420
bool removeFirst()
Definition: qinternallist.h:67
const char * getKeyAscii() const
Definition: qgcache.cpp:808
void * key
Definition: qgcache.cpp:66
bool remove_int(QCacheItem *item)
Definition: qgcache.cpp:218
QCListIt * it
Definition: qgcache.h:126
QCollection::Item take_string(const QString &key)
Definition: qgdict.cpp:788
QCollection::Item take_other(const char *key)
Definition: qgcache.cpp:466
QCacheItem * find_int(long key) const
Definition: qgcache.cpp:197
type * next()
Definition: qinternallist.h:89
int hits
Definition: qgcache.cpp:104
void clear()
Definition: qgcache.cpp:493
bool atLast() const
Definition: qgcache.cpp:754
int tCost
Definition: qgcache.h:95
QCacheItem * take_int(long key)
Definition: qgcache.cpp:204
void setAutoDelete(bool enable)
Definition: qcollection.h:55
The QGDict class is an internal class for implementing QDict template classes.
Definition: qgdict.h:104
QCollection::Item operator--()
Definition: qgcache.cpp:863
QCDict * dict
Definition: qgcache.h:93
bool remove_int(long key, QCollection::Item item=0)
Definition: qgdict.cpp:762
QCollection::Item operator()()
Definition: qgcache.cpp:830
QLNode * node
Definition: qgcache.cpp:68
QCList()
Definition: qgcache.cpp:81
#define CHECK_PTR(p)
Definition: qglobal.h:601
KeyType
Definition: qgdict.h:119
bool insert_other(const char *key, QCollection::Item, int cost, int priority)
Definition: qgcache.cpp:380
void line(double t, double *p, double &x, double &y, double &z)
QCacheItem * last()
Definition: qgcache.cpp:95
QCacheItem * take_string(const QString &key)
Definition: qgcache.cpp:200
int dumpCosts
Definition: qgcache.cpp:107
QCacheItem * take_ascii(const char *key)
Definition: qgcache.cpp:202
char * qstrdup(const char *str)
Definition: qcstring.cpp:548
int mCost
Definition: qgcache.h:94
uint count() const
Definition: qgcache.cpp:734
static const Null null
Definition: qstring.h:376
QCollection::Item get() const
Definition: qgcache.cpp:786
QCollection::Item take_int(long key)
Definition: qgdict.cpp:822
virtual void deleteItem(Item)
type * last()
Definition: qinternallist.h:88
void qFatal(const char *msg,...)
Definition: qglobal.cpp:443
QCollection::Item toLast()
Definition: qgcache.cpp:775
void setAutoDelete(bool del)
Definition: qgcache.cpp:89
unsigned uint
Definition: qglobal.h:351
The QLNode class is an internal class for the QList template collection.
Definition: qglist.h:50
bool removeLast()
Definition: qinternallist.h:68
const bool TRUE
Definition: qglobal.h:371
QCListIt(const QCList *p)
Definition: qgcache.cpp:172
QString getKeyString() const
Definition: qgcache.cpp:797
int finds
Definition: qgcache.cpp:103
#define ASSERT(x)
Definition: qglobal.h:590
bool removeLast()
Definition: qgcache.cpp:92
QCollection::Item look_string(const QString &key, QCollection::Item, int)
Definition: qgdict.cpp:382
QCollection::Item data
Definition: qgcache.cpp:67
void * Item
Definition: qcollection.h:60