TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator Class Reference

#include <Table.h>

Public Member Functions

bool operator!= (const Iterator &other) const
 
bool operator== (const Iterator &other) const
 
Iteratoroperator++ ()
 
Iterator operator++ (int)
 
const Entryoperator* () const
 
const Valuevalue () const
 
const Key & key () const
 
Entryoperator-> () const
 
 operator Entry * () const
 
bool isValid () const
 
bool hasMore () const
 

Private Member Functions

 Iterator ()
 
 Iterator (size_t numBuckets, Node **m_bucket)
 
void findNext ()
 

Private Attributes

size_t index
 
Nodenode
 
size_t m_numBuckets
 
Node ** m_bucket
 
bool isDone
 

Friends

class Table< Key, Value, HashFunc, EqualsFunc >
 

Detailed Description

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
class G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator

C++ STL style iterator variable. See begin().

Constructor & Destructor Documentation

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::Iterator ( )
inlineprivate

Creates the end iterator.

437  : index(0), node(NULL), m_bucket(NULL) {
438  isDone = true;
439  }
size_t index
Definition: Table.h:423
arena_t NULL
Definition: jemalloc_internal.h:624
Node * node
Definition: Table.h:428
Node ** m_bucket
Definition: Table.h:431
bool isDone
Definition: Table.h:432
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::Iterator ( size_t  numBuckets,
Node **  m_bucket 
)
inlineprivate
441  :
442  index(0),
443  node(NULL),
444  m_numBuckets(numBuckets),
445  m_bucket(m_bucket) {
446 
447  if (m_numBuckets == 0) {
448  // Empty table
449  isDone = true;
450  return;
451  }
452 
453 # ifdef G3D_DEBUG
454  for (unsigned int i = 0; i < m_numBuckets; ++i) {
456  }
457 # endif
458 
459  index = 0;
460  node = m_bucket[index];
462  isDone = false;
463  findNext();
465  }
size_t m_numBuckets
Definition: Table.h:430
size_t index
Definition: Table.h:423
arena_t NULL
Definition: jemalloc_internal.h:624
Node * node
Definition: Table.h:428
#define debugAssert(exp)
Definition: debugAssert.h:160
Node ** m_bucket
Definition: Table.h:431
bool isDone
Definition: Table.h:432
void findNext()
Definition: Table.h:471
bool isValidHeapPointer(const void *x)
Definition: debug.h:38

+ Here is the call graph for this function:

Member Function Documentation

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
void G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::findNext ( )
inlineprivate

If node is NULL, then finds the next element by searching through the bucket array. Sets isDone if no more nodes are available.

471  {
472  while (node == NULL) {
473  ++index;
474  if (index >= m_numBuckets) {
475  m_bucket = NULL;
476  index = 0;
477  isDone = true;
478  return;
479  } else {
480  node = m_bucket[index];
482  }
483  }
485  }
size_t m_numBuckets
Definition: Table.h:430
size_t index
Definition: Table.h:423
arena_t NULL
Definition: jemalloc_internal.h:624
Node * node
Definition: Table.h:428
#define debugAssert(exp)
Definition: debugAssert.h:160
Node ** m_bucket
Definition: Table.h:431
bool isDone
Definition: Table.h:432
bool isValidHeapPointer(const void *x)
Definition: debug.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::hasMore ( ) const
inline
Deprecated:
Use isValid
551  {
552  return ! isDone;
553  }
bool isDone
Definition: Table.h:432

+ Here is the caller graph for this function:

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::isValid ( ) const
inline
546  {
547  return ! isDone;
548  }
bool isDone
Definition: Table.h:432
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
const Key& G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::key ( ) const
inline
532  {
533  return node->entry.key;
534  }
Node * node
Definition: Table.h:428
Key key
Definition: Table.h:109
Entry entry
Definition: Table.h:127
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator Entry * ( ) const
inline
541  {
543  return &(node->entry);
544  }
Node * node
Definition: Table.h:428
#define debugAssert(exp)
Definition: debugAssert.h:160
Entry entry
Definition: Table.h:127
bool isValidHeapPointer(const void *x)
Definition: debug.h:38

+ Here is the call graph for this function:

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator!= ( const Iterator other) const
inline
488  {
489  return !(*this == other);
490  }
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
const Entry& G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator* ( ) const
inline
524  {
525  return node->entry;
526  }
Node * node
Definition: Table.h:428
Entry entry
Definition: Table.h:127
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Iterator& G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator++ ( )
inline

Pre increment.

504  {
505  debugAssert(! isDone);
506  debugAssert(node != NULL);
509  node = node->next;
510  findNext();
512  return *this;
513  }
arena_t NULL
Definition: jemalloc_internal.h:624
Node * node
Definition: Table.h:428
#define debugAssert(exp)
Definition: debugAssert.h:160
Node * next
Definition: Table.h:129
bool isDone
Definition: Table.h:432
void findNext()
Definition: Table.h:471
bool isValidHeapPointer(const void *x)
Definition: debug.h:38

+ Here is the call graph for this function:

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Iterator G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator++ ( int  )
inline

Post increment (slower than preincrement).

518  {
519  Iterator old = *this;
520  ++(*this);
521  return old;
522  }
Iterator()
Definition: Table.h:437
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Entry* G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator-> ( ) const
inline
536  {
538  return &(node->entry);
539  }
Node * node
Definition: Table.h:428
#define debugAssert(exp)
Definition: debugAssert.h:160
Entry entry
Definition: Table.h:127
bool isValidHeapPointer(const void *x)
Definition: debug.h:38

+ Here is the call graph for this function:

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::operator== ( const Iterator other) const
inline
492  {
493  if (other.isDone || isDone) {
494  // Common case; check against isDone.
495  return (isDone == other.isDone);
496  } else {
497  return (node == other.node) && (index == other.index);
498  }
499  }
size_t index
Definition: Table.h:423
Node * node
Definition: Table.h:428
bool isDone
Definition: Table.h:432
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
const Value& G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::value ( ) const
inline
528  {
529  return node->entry.value;
530  }
Node * node
Definition: Table.h:428
Value value
Definition: Table.h:110
Entry entry
Definition: Table.h:127

Friends And Related Function Documentation

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
friend class Table< Key, Value, HashFunc, EqualsFunc >
friend

Member Data Documentation

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
size_t G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::index
private

Bucket index.

template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::isDone
private
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Node** G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::m_bucket
private
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
size_t G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::m_numBuckets
private
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Node* G3D::Table< Key, Value, HashFunc, EqualsFunc >::Iterator::node
private

Linked list node.


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