KiCad PCB EDA Suite
MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL > Class Template Reference

Multivector container type. More...

#include <multivector.h>

Classes

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

Public Types

typedef boost::ptr_vector< T > ITEM_PTR_VECTOR
 Helper for defining a list of library draw object pointers. More...
 
typedef ITERATOR_BASE< T, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
 The const iterator. More...
 
typedef ITERATOR_BASE< const T, const MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::const_iterator > CONST_ITERATOR
 

Public Member Functions

 MULTIVECTOR ()
 
void push_back (T *aItem)
 
ITERATOR erase (const ITERATOR &aIterator)
 
ITERATOR begin (int aType=UNDEFINED_TYPE)
 
ITERATOR end (int aType=UNDEFINED_TYPE)
 
CONST_ITERATOR begin (int aType=UNDEFINED_TYPE) const
 
CONST_ITERATOR end (int aType=UNDEFINED_TYPE) const
 
void clear (int aType=UNDEFINED_TYPE)
 
size_t size (int aType=UNDEFINED_TYPE) const
 
bool empty (int aType=UNDEFINED_TYPE) const
 
void sort ()
 
void unique ()
 Remove duplicate elements in list. More...
 
ITEM_PTR_VECTORoperator[] (int aType)
 
const ITEM_PTR_VECTORoperator[] (int aType) const
 

Static Public Attributes

static constexpr int UNDEFINED_TYPE = 0
 Type value to indicate no specific type. More...
 
static constexpr int FIRST_TYPE = FIRST_TYPE_VAL
 
static constexpr int LAST_TYPE = LAST_TYPE_VAL
 
static constexpr int TYPES_COUNT = LAST_TYPE - FIRST_TYPE + 1
 

Private Member Functions

int first () const
 < Get first non-empty type or first type if all are empty. More...
 
int last () const
 Contained items by type. More...
 

Private Attributes

ITEM_PTR_VECTOR m_data [TYPES_COUNT]
 

Detailed Description

template<typename T, int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
class MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >

Multivector container type.

Keeps items segregated by their type in multiple ptr_vectors. Provides both access as a flat list as well as access by type of item.

T is the stored type, needs to provide Type() method used to segregate items. FIRST_TYPE_VAL is the lower boundary value of the types stored in the container. LAST_TYPE_VAL is the upper boundary value of the types stored in the container.

Definition at line 45 of file multivector.h.

Member Typedef Documentation

◆ CONST_ITERATOR

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
typedef ITERATOR_BASE<const T, const MULTIVECTOR<T, FIRST_TYPE_VAL, LAST_TYPE_VAL>, typename ITEM_PTR_VECTOR::const_iterator> MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::CONST_ITERATOR

Definition at line 167 of file multivector.h.

◆ ITEM_PTR_VECTOR

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
typedef boost::ptr_vector<T> MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITEM_PTR_VECTOR

Helper for defining a list of library draw object pointers.

The Boost pointer containers are responsible for deleting object pointers placed in them. If you access a object pointer from the list, do not delete it directly.

Definition at line 64 of file multivector.h.

◆ ITERATOR

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
typedef ITERATOR_BASE<T, MULTIVECTOR<T, FIRST_TYPE_VAL, LAST_TYPE_VAL>, typename ITEM_PTR_VECTOR::iterator> MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::ITERATOR

The const iterator.

Definition at line 164 of file multivector.h.

Constructor & Destructor Documentation

◆ MULTIVECTOR()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::MULTIVECTOR ( )
inline

Definition at line 170 of file multivector.h.

171 {
172 }

Member Function Documentation

◆ begin() [1/2]

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
ITERATOR MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin ( int  aType = UNDEFINED_TYPE)
inline

Definition at line 188 of file multivector.h.

189 {
190 int bucket = ( aType != UNDEFINED_TYPE ) ? aType : first();
191 return ITERATOR( this, operator[]( bucket ).begin(), bucket, aType );
192 }
ITERATOR_BASE< T, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
The const iterator.
Definition: multivector.h:164
int first() const
< Get first non-empty type or first type if all are empty.
Definition: multivector.h:298
static constexpr int UNDEFINED_TYPE
Type value to indicate no specific type.
Definition: multivector.h:52
ITERATOR begin(int aType=UNDEFINED_TYPE)
Definition: multivector.h:188

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::first(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::UNDEFINED_TYPE.

Referenced by MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin(), LIB_SYMBOL::Compare(), CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins(), LIB_SYMBOL::SetConversion(), and LIB_SYMBOL::SetUnitCount().

◆ begin() [2/2]

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
CONST_ITERATOR MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin ( int  aType = UNDEFINED_TYPE) const
inline

Definition at line 200 of file multivector.h.

201 {
202 int bucket = ( aType != UNDEFINED_TYPE ) ? aType : first();
203 return CONST_ITERATOR( this, operator[]( bucket ).begin(), bucket, aType );
204 }
ITERATOR_BASE< const T, const MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::const_iterator > CONST_ITERATOR
Definition: multivector.h:167

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::first(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::UNDEFINED_TYPE.

◆ clear()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
void MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::clear ( int  aType = UNDEFINED_TYPE)
inline

◆ empty()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
bool MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::empty ( int  aType = UNDEFINED_TYPE) const
inline

◆ end() [1/2]

◆ end() [2/2]

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
CONST_ITERATOR MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::end ( int  aType = UNDEFINED_TYPE) const
inline

Definition at line 206 of file multivector.h.

207 {
208 int bucket = ( aType != UNDEFINED_TYPE ) ? aType : last();
209 return CONST_ITERATOR( this, operator[]( bucket ).end(), bucket, aType );
210 }

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::end(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::last(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::UNDEFINED_TYPE.

◆ erase()

◆ first()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
int MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::first ( ) const
inlineprivate

◆ last()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
int MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::last ( ) const
inlineprivate

◆ operator[]() [1/2]

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
ITEM_PTR_VECTOR & MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::operator[] ( int  aType)
inline

Definition at line 265 of file multivector.h.

266 {
267 if( ( aType < FIRST_TYPE ) || ( aType > LAST_TYPE ) )
268 {
269 wxFAIL_MSG( wxT( "Attempted access to type not within MULTIVECTOR" ) );
270
271 // return type is a reference so we have to return something...
272 aType = FIRST_TYPE;
273 }
274
275 return m_data[ aType - FIRST_TYPE ];
276 }
static constexpr int FIRST_TYPE
Definition: multivector.h:292
static constexpr int LAST_TYPE
Definition: multivector.h:293

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::FIRST_TYPE, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::LAST_TYPE, and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::m_data.

Referenced by MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::clear(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::push_back(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

◆ operator[]() [2/2]

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
const ITEM_PTR_VECTOR & MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::operator[] ( int  aType) const
inline

Definition at line 278 of file multivector.h.

279 {
280 if( ( aType < FIRST_TYPE ) || ( aType > LAST_TYPE ) )
281 {
282 wxFAIL_MSG( wxT( "Attempted access to type not within MULTIVECTOR" ) );
283
284 // return type is a reference so we have to return something...
285 aType = FIRST_TYPE;
286 }
287
288 return m_data[ aType - FIRST_TYPE ];
289 }

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::FIRST_TYPE, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::LAST_TYPE, and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::m_data.

◆ push_back()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
void MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::push_back ( T *  aItem)
inline

◆ size()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
size_t MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size ( int  aType = UNDEFINED_TYPE) const
inline

◆ sort()

◆ unique()

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
void MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::unique ( )
inline

Remove duplicate elements in list.

Definition at line 256 of file multivector.h.

257 {
258 for( int i = 0; i < TYPES_COUNT; ++i )
259 {
260 if( m_data[ i ].size() > 1 )
261 m_data[ i ].unique();
262 }
263 }

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::m_data, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::TYPES_COUNT.

Referenced by LIB_SYMBOL::RemoveDuplicateDrawItems().

Member Data Documentation

◆ FIRST_TYPE

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
constexpr int MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::FIRST_TYPE = FIRST_TYPE_VAL
staticconstexpr

◆ LAST_TYPE

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
constexpr int MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::LAST_TYPE = LAST_TYPE_VAL
staticconstexpr

◆ m_data

◆ TYPES_COUNT

◆ UNDEFINED_TYPE

template<typename T , int FIRST_TYPE_VAL, int LAST_TYPE_VAL>
constexpr int MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::UNDEFINED_TYPE = 0
staticconstexpr

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