Public Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
QGDictIterator Class Reference

An internal class for implementing QDictIterator and QIntDictIterator. More...

#include <qgdict.h>

Inheritance diagram for QGDictIterator:
QAsciiDictIterator< type > QIntDictIterator< type > QIntDictIterator< RefItem > QPtrDictIterator< type >

Public Member Functions

 QGDictIterator (const QGDict &)
 
 QGDictIterator (const QGDictIterator &)
 
QGDictIteratoroperator= (const QGDictIterator &)
 
 ~QGDictIterator ()
 
QCollection::Item toFirst ()
 
QCollection::Item get () const
 
QString getKeyString () const
 
const char * getKeyAscii () const
 
intptr_t getKeyInt () const
 
void * getKeyPtr () const
 
QCollection::Item operator() ()
 
QCollection::Item operator++ ()
 
QCollection::Item operator+= (uint)
 

Protected Attributes

QGDictdict
 

Private Attributes

QBaseBucketcurNode
 
uint curIndex
 

Friends

class QGDict
 

Detailed Description

An internal class for implementing QDictIterator and QIntDictIterator.

QGDictIterator is a strictly internal class that does the heavy work for QDictIterator and QIntDictIterator.

Definition at line 167 of file qgdict.h.

Constructor & Destructor Documentation

QGDictIterator::QGDictIterator ( const QGDict d)

Definition at line 1101 of file qgdict.cpp.

1102 {
1103  dict = (QGDict *)&d; // get reference to dict
1104  toFirst(); // set to first noe
1105  if ( !dict->iterators ) {
1106  dict->iterators = new QGDItList; // create iterator list
1107  CHECK_PTR( dict->iterators );
1108  }
1109  dict->iterators->append( this ); // attach iterator to dict
1110 }
void append(const type *d)
Definition: qinternallist.h:61
QCollection::Item toFirst()
Definition: qgdict.cpp:1161
QGDict * dict
Definition: qgdict.h:189
The QGDict class is an internal class for implementing QDict template classes.
Definition: qgdict.h:104
#define CHECK_PTR(p)
Definition: qglobal.h:601
QGDItList * iterators
Definition: qgdict.h:155
QGDictIterator::QGDictIterator ( const QGDictIterator it)

Definition at line 1117 of file qgdict.cpp.

1118 {
1119  dict = it.dict;
1120  curNode = it.curNode;
1121  curIndex = it.curIndex;
1122  if ( dict )
1123  dict->iterators->append( this ); // attach iterator to dict
1124 }
QBaseBucket * curNode
Definition: qgdict.h:192
void append(const type *d)
Definition: qinternallist.h:61
uint curIndex
Definition: qgdict.h:193
QGDict * dict
Definition: qgdict.h:189
QGDItList * iterators
Definition: qgdict.h:155
QGDictIterator::~QGDictIterator ( )

Definition at line 1149 of file qgdict.cpp.

1150 {
1151  if ( dict ) // detach iterator from dict
1152  dict->iterators->removeRef( this );
1153 }
bool removeRef(const type *d)
Definition: qinternallist.h:65
QGDict * dict
Definition: qgdict.h:189
QGDItList * iterators
Definition: qgdict.h:155

Member Function Documentation

QCollection::Item QGDictIterator::get ( ) const
inline

Definition at line 196 of file qgdict.h.

197 {
198  return curNode ? curNode->getData() : 0;
199 }
QCollection::Item getData()
Definition: qgdict.h:53
QBaseBucket * curNode
Definition: qgdict.h:192
const char * QGDictIterator::getKeyAscii ( ) const
inline

Definition at line 206 of file qgdict.h.

207 {
208  return curNode ? ((QAsciiBucket*)curNode)->getKey() : 0;
209 }
QBaseBucket * curNode
Definition: qgdict.h:192
intptr_t QGDictIterator::getKeyInt ( ) const
inline

Definition at line 211 of file qgdict.h.

212 {
213  return curNode ? ((QIntBucket*)curNode)->getKey() : 0;
214 }
QBaseBucket * curNode
Definition: qgdict.h:192
void * QGDictIterator::getKeyPtr ( ) const
inline

Definition at line 216 of file qgdict.h.

217 {
218  return curNode ? ((QPtrBucket*)curNode)->getKey() : 0;
219 }
QBaseBucket * curNode
Definition: qgdict.h:192
QString QGDictIterator::getKeyString ( ) const
inline

Definition at line 201 of file qgdict.h.

202 {
203  return curNode ? ((QStringBucket*)curNode)->getKey() : QString::null;
204 }
QBaseBucket * curNode
Definition: qgdict.h:192
static const Null null
Definition: qstring.h:376
QCollection::Item QGDictIterator::operator() ( )

Definition at line 1188 of file qgdict.cpp.

1189 {
1190  if ( !dict ) {
1191 #if defined(CHECK_NULL)
1192  qWarning( "QGDictIterator::operator(): Dictionary has been deleted" );
1193 #endif
1194  return 0;
1195  }
1196  if ( !curNode )
1197  return 0;
1199  this->operator++();
1200  return d;
1201 }
QCollection::Item getData()
Definition: qgdict.h:53
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
QBaseBucket * curNode
Definition: qgdict.h:192
QCollection::Item operator++()
Definition: qgdict.cpp:1208
QGDict * dict
Definition: qgdict.h:189
void * Item
Definition: qcollection.h:60
QCollection::Item QGDictIterator::operator++ ( )

Definition at line 1208 of file qgdict.cpp.

1209 {
1210  if ( !dict ) {
1211 #if defined(CHECK_NULL)
1212  qWarning( "QGDictIterator::operator++: Dictionary has been deleted" );
1213 #endif
1214  return 0;
1215  }
1216  if ( !curNode )
1217  return 0;
1218  curNode = curNode->getNext();
1219  if ( !curNode ) { // no next bucket
1220  register uint i = curIndex + 1; // look from next vec element
1221  register QBaseBucket **v = &dict->vec[i];
1222  while ( i < dict->size() && !(*v++) )
1223  i++;
1224  if ( i == dict->size() ) { // nothing found
1225  curNode = 0;
1226  return 0;
1227  }
1228  curNode = dict->vec[i];
1229  curIndex = i;
1230  }
1231  return curNode->getData();
1232 }
QBaseBucket ** vec
Definition: qgdict.h:149
QCollection::Item getData()
Definition: qgdict.h:53
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
QBaseBucket * curNode
Definition: qgdict.h:192
QBaseBucket * getNext()
Definition: qgdict.h:55
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
uint curIndex
Definition: qgdict.h:193
QGDict * dict
Definition: qgdict.h:189
uint size() const
Definition: qgdict.h:108
unsigned uint
Definition: qglobal.h:351
QCollection::Item QGDictIterator::operator+= ( uint  jumps)

Definition at line 1239 of file qgdict.cpp.

1240 {
1241  while ( curNode && jumps-- )
1242  operator++();
1243  return curNode ? curNode->getData() : 0;
1244 }
QCollection::Item getData()
Definition: qgdict.h:53
QBaseBucket * curNode
Definition: qgdict.h:192
QCollection::Item operator++()
Definition: qgdict.cpp:1208
QGDictIterator & QGDictIterator::operator= ( const QGDictIterator it)

Definition at line 1132 of file qgdict.cpp.

1133 {
1134  if ( dict ) // detach from old dict
1135  dict->iterators->removeRef( this );
1136  dict = it.dict;
1137  curNode = it.curNode;
1138  curIndex = it.curIndex;
1139  if ( dict )
1140  dict->iterators->append( this ); // attach to new list
1141  return *this;
1142 }
QBaseBucket * curNode
Definition: qgdict.h:192
bool removeRef(const type *d)
Definition: qinternallist.h:65
void append(const type *d)
Definition: qinternallist.h:61
uint curIndex
Definition: qgdict.h:193
QGDict * dict
Definition: qgdict.h:189
QGDItList * iterators
Definition: qgdict.h:155
QCollection::Item QGDictIterator::toFirst ( )

Definition at line 1161 of file qgdict.cpp.

1162 {
1163  if ( !dict ) {
1164 #if defined(CHECK_NULL)
1165  qWarning( "QGDictIterator::toFirst: Dictionary has been deleted" );
1166 #endif
1167  return 0;
1168  }
1169  if ( dict->count() == 0 ) { // empty dictionary
1170  curNode = 0;
1171  return 0;
1172  }
1173  register uint i = 0;
1174  register QBaseBucket **v = dict->vec;
1175  while ( !(*v++) )
1176  i++;
1177  curNode = dict->vec[i];
1178  curIndex = i;
1179  return curNode->getData();
1180 }
uint count() const
Definition: qgdict.h:107
QBaseBucket ** vec
Definition: qgdict.h:149
QCollection::Item getData()
Definition: qgdict.h:53
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
QBaseBucket * curNode
Definition: qgdict.h:192
uint curIndex
Definition: qgdict.h:193
QGDict * dict
Definition: qgdict.h:189
unsigned uint
Definition: qglobal.h:351

Friends And Related Function Documentation

friend class QGDict
friend

Definition at line 169 of file qgdict.h.

Member Data Documentation

uint QGDictIterator::curIndex
private

Definition at line 193 of file qgdict.h.

QBaseBucket* QGDictIterator::curNode
private

Definition at line 192 of file qgdict.h.

QGDict* QGDictIterator::dict
protected

Definition at line 189 of file qgdict.h.


The documentation for this class was generated from the following files: