KiCad PCB EDA Suite
MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT > Class Template Reference

Generic implementation of a flat const/non-const iterator over contained items. More...

#include <multivector.h>

Public Member Functions

ITEM_TYPE & operator* ()
 
ITEM_TYPE * operator-> ()
 
ITERATOR_BASEoperator++ ()
 
bool operator!= (const ITERATOR_BASE &aOther) const
 

Protected Member Functions

 ITERATOR_BASE (ITEM_CONTAINER *aItems, ITEM_CONTAINER_IT aIt, int aBucket, int aType=UNDEFINED_TYPE)
 Constructor. More...
 
void validate ()
 

Assures the iterator is in a valid state.

More...
 

Protected Attributes

ITEM_CONTAINER * m_parent
 

Wrapped container

More...
 
ITEM_CONTAINER_IT m_it
 

Iterator for one of the ptr_vector containers stored in the array

More...
 
bool m_filter
 

Flag indicating whether type filtering is enabled

More...
 
int m_curType
 

Type of the currently iterated items

More...
 

Friends

class MULTIVECTOR
 

Detailed Description

template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE, typename ITEM_CONTAINER, typename ITEM_CONTAINER_IT>
class MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >

Generic implementation of a flat const/non-const iterator over contained items.

Definition at line 66 of file multivector.h.

Constructor & Destructor Documentation

template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::ITERATOR_BASE ( ITEM_CONTAINER *  aItems,
ITEM_CONTAINER_IT  aIt,
int  aBucket,
int  aType = UNDEFINED_TYPE 
)
inlineprotected

Constructor.

Parameters
aItemsis the container to wrap.
aItis the iterator to initialize this iterator (usually some begin() or end() iterator).
aBucketis the type ID of the given iterator.
aTypeenables item type filtering. When aType is UNDEFINED_TYPE, there is no filtering and all item types are accessible by the iterator.

Definition at line 113 of file multivector.h.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_filter, and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::UNDEFINED_TYPE.

115  : m_parent( aItems ), m_it( aIt ), m_curType( aBucket )
116  {
117  m_filter = ( aType != UNDEFINED_TYPE );
118  }
bool m_filter
Flag indicating whether type filtering is enabled
Definition: multivector.h:151
static constexpr int UNDEFINED_TYPE
Type value to indicate no specific type.
Definition: multivector.h:50
ITEM_CONTAINER * m_parent
Wrapped container
Definition: multivector.h:145
int m_curType
Type of the currently iterated items
Definition: multivector.h:154
ITEM_CONTAINER_IT m_it
Iterator for one of the ptr_vector containers stored in the array
Definition: multivector.h:148

Member Function Documentation

template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
bool MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::operator!= ( const ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT > &  aOther) const
inline

Definition at line 89 of file multivector.h.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_curType, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_filter, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_it, and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_parent.

90  {
91  if( aOther.m_parent != m_parent )
92  return true;
93 
94  if( aOther.m_filter != m_filter )
95  return true;
96 
97  if( aOther.m_curType != m_curType )
98  return true;
99 
100  return aOther.m_it != m_it;
101  }
bool m_filter
Flag indicating whether type filtering is enabled
Definition: multivector.h:151
ITEM_CONTAINER * m_parent
Wrapped container
Definition: multivector.h:145
int m_curType
Type of the currently iterated items
Definition: multivector.h:154
ITEM_CONTAINER_IT m_it
Iterator for one of the ptr_vector containers stored in the array
Definition: multivector.h:148
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
ITEM_TYPE& MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::operator* ( )
inline

Definition at line 69 of file multivector.h.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_it.

70  {
71  return *m_it;
72  }
ITEM_CONTAINER_IT m_it
Iterator for one of the ptr_vector containers stored in the array
Definition: multivector.h:148
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
ITERATOR_BASE& MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::operator++ ( )
inline
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
ITEM_TYPE* MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::operator-> ( )
inline

Definition at line 74 of file multivector.h.

75  {
76  return &( *m_it );
77  }
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
void MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::validate ( void  )
inlineprotected

Assures the iterator is in a valid state.

Definition at line 121 of file multivector.h.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::empty(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::end(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::LAST_TYPE, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_curType, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_filter, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_it, and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_parent.

Referenced by MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::operator++().

122  {
123  // for all-items iterators (unfiltered): check if this is the end of the
124  // current type container, if so switch to the next non-empty container
125  if( !m_filter && m_it == (*m_parent)[ m_curType ].end() )
126  {
127  // switch to the next type (look for a not empty container)
128  int nextType = m_curType;
129 
130  do
131  ++nextType;
132  while( ( nextType <= LAST_TYPE ) && (*m_parent)[ nextType ].empty() );
133 
134  // there is another not empty container, so make the iterator point to it,
135  // otherwise it means the iterator points to the last item
136  if( nextType <= LAST_TYPE )
137  {
138  m_curType = nextType;
139  m_it = (*m_parent)[ m_curType ].begin();
140  }
141  }
142  }
bool m_filter
Flag indicating whether type filtering is enabled
Definition: multivector.h:151
bool empty(int aType=UNDEFINED_TYPE)
Definition: multivector.h:224
static constexpr int LAST_TYPE
Definition: multivector.h:265
ITERATOR end(int aType=UNDEFINED_TYPE)
Definition: multivector.h:189
ITEM_CONTAINER * m_parent
Wrapped container
Definition: multivector.h:145
int m_curType
Type of the currently iterated items
Definition: multivector.h:154
ITEM_CONTAINER_IT m_it
Iterator for one of the ptr_vector containers stored in the array
Definition: multivector.h:148

Friends And Related Function Documentation

template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
friend class MULTIVECTOR
friend

Definition at line 156 of file multivector.h.

Member Data Documentation

template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
int MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_curType
protected
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
bool MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_filter
protected
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
ITEM_CONTAINER_IT MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_it
protected
template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
template<typename ITEM_TYPE , typename ITEM_CONTAINER , typename ITEM_CONTAINER_IT >
ITEM_CONTAINER* MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR_BASE< ITEM_TYPE, ITEM_CONTAINER, ITEM_CONTAINER_IT >::m_parent
protected

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