add more constness to connecivity algo

also make ForEachAnchor inlineable, like ForEachItem.
remove some unused function declarations.
This commit is contained in:
Oleg Endo 2020-04-13 04:10:57 +09:00 committed by Jon Evans
parent 3de5b98316
commit 4c7471eb79
4 changed files with 29 additions and 21 deletions

View File

@ -747,16 +747,6 @@ void CN_CONNECTIVITY_ALGO::Clear()
}
void CN_CONNECTIVITY_ALGO::ForEachAnchor( const std::function<void( CN_ANCHOR& )>& aFunc )
{
ForEachItem( [aFunc] ( CN_ITEM& item ) {
for( const auto& anchor : item.Anchors() )
aFunc( *anchor );
}
);
}
void CN_CONNECTIVITY_ALGO::SetProgressReporter( PROGRESS_REPORTER* aReporter )
{
m_progressReporter = aReporter;

View File

@ -173,7 +173,7 @@ public:
CN_CONNECTIVITY_ALGO() {}
~CN_CONNECTIVITY_ALGO() { Clear(); }
bool ItemExists( const BOARD_CONNECTED_ITEM* aItem )
bool ItemExists( const BOARD_CONNECTED_ITEM* aItem ) const
{
return m_itemMap.find( aItem ) != m_itemMap.end();
}
@ -197,7 +197,7 @@ public:
*i = false;
}
void GetDirtyClusters( CLUSTERS& aClusters )
void GetDirtyClusters( CLUSTERS& aClusters ) const
{
for( const auto& cl : m_ratsnestClusters )
{
@ -240,17 +240,25 @@ public:
*/
void FindIsolatedCopperIslands( std::vector<CN_ZONE_ISOLATED_ISLAND_LIST>& aZones );
bool CheckConnectivity( std::vector<CN_DISJOINT_NET_ENTRY>& aReport );
const CLUSTERS& GetClusters();
int GetUnconnectedCount();
CN_LIST& ItemList() { return m_itemList; }
void ForEachAnchor( const std::function<void( CN_ANCHOR& )>& aFunc );
const CN_LIST& ItemList() const
{
return m_itemList;
}
template <typename Func>
void ForEachItem( Func&& aFunc )
void ForEachAnchor( Func&& aFunc ) const
{
for( auto&& item : m_itemList )
{
for( auto&& anchor : item->Anchors() )
aFunc( *anchor );
}
}
template <typename Func>
void ForEachItem( Func&& aFunc ) const
{
for( auto&& item : m_itemList )
aFunc( *item );

View File

@ -504,7 +504,7 @@ unsigned int CONNECTIVITY_DATA::GetPadCount( int aNet ) const
{
int n = 0;
for( auto pad : m_connAlgo->ItemList() )
for( auto&& pad : m_connAlgo->ItemList() )
{
if( !pad->Valid() || pad->Parent()->Type() != PCB_PAD_T)
continue;

View File

@ -426,10 +426,20 @@ public:
}
using ITER = decltype( m_items )::iterator;
using CONST_ITER = decltype( m_items )::const_iterator;
ITER begin() { return m_items.begin(); };
ITER end() { return m_items.end(); };
CONST_ITER begin() const
{
return m_items.begin();
}
CONST_ITER end() const
{
return m_items.end();
}
CN_ITEM* operator[] ( int aIndex ) { return m_items[aIndex]; }
template <class T>