Unify SCH_PIN ambiguity in equality operator

Remove != operator that is not used for C++20 and reworked
SCH_PIN==SCH_ITEM operator that was not reciprocal
This commit is contained in:
Seth Hillbrand 2024-05-31 13:42:36 -07:00
parent c6499cf5db
commit 79a354bf0e
5 changed files with 21 additions and 35 deletions

View File

@ -1830,12 +1830,12 @@ bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const
for( auto it1 = thisPinList.begin(), it2 = otherPinList.begin(); for( auto it1 = thisPinList.begin(), it2 = otherPinList.begin();
it1 != thisPinList.end(); ++it1, ++it2 ) it1 != thisPinList.end(); ++it1, ++it2 )
{ {
if( !( **it1 == **it2 ) ) if( **it1 != **it2 )
return false; return false;
} }
for( size_t ii = 0; ii < thisPinList.size(); ++ii ) for( size_t ii = 0; ii < thisPinList.size(); ++ii )
{ {
if( !( *thisPinList[ii] == *otherPinList[ii] ) ) if( *thisPinList[ii] != *otherPinList[ii] )
return false; return false;
} }

View File

@ -119,14 +119,6 @@ public:
&& GetParent() == aB.GetParent(); && GetParent() == aB.GetParent();
} }
bool operator!=( const DANGLING_END_ITEM& aB ) const
{
return GetItem() != aB.GetItem()
|| GetPosition() != aB.GetPosition()
|| GetType() != aB.GetType()
|| GetParent() != aB.GetParent();;
}
bool operator<( const DANGLING_END_ITEM& rhs ) const bool operator<( const DANGLING_END_ITEM& rhs ) const
{ {
return( m_pos.x < rhs.m_pos.x || ( m_pos.x == rhs.m_pos.x && m_pos.y < rhs.m_pos.y ) return( m_pos.x < rhs.m_pos.x || ( m_pos.x == rhs.m_pos.x && m_pos.y < rhs.m_pos.y )

View File

@ -2028,63 +2028,58 @@ wxString SCH_PIN::getItemDescription( ALT* aAlt ) const
} }
bool SCH_PIN::operator==( const SCH_ITEM& aOther ) const bool SCH_PIN::operator==( const SCH_PIN& aOther ) const
{ {
if( aOther.Type() != SCH_PIN_T ) if( m_number != aOther.m_number )
return false; return false;
const SCH_PIN* other = static_cast<const SCH_PIN*>( &aOther ); if( m_position != aOther.m_position )
if( m_number != other->m_number )
return false;
if( m_position != other->m_position )
return false; return false;
if( dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) ) if( dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
{ {
if( m_libPin != other->m_libPin ) if( m_libPin != aOther.m_libPin )
return false; return false;
if( m_alt != other->m_alt ) if( m_alt != aOther.m_alt )
return false; return false;
} }
if( dynamic_cast<const LIB_SYMBOL*>( GetParentSymbol() ) ) if( dynamic_cast<const LIB_SYMBOL*>( GetParentSymbol() ) )
{ {
if( m_length != other->m_length ) if( m_length != aOther.m_length )
return false; return false;
if( m_orientation != other->m_orientation ) if( m_orientation != aOther.m_orientation )
return false; return false;
if( m_shape != other->m_shape ) if( m_shape != aOther.m_shape )
return false; return false;
if( m_type != other->m_type ) if( m_type != aOther.m_type )
return false; return false;
if( m_name != other->m_name ) if( m_name != aOther.m_name )
return false; return false;
if( m_hidden != other->m_hidden ) if( m_hidden != aOther.m_hidden )
return false; return false;
if( m_numTextSize != other->m_numTextSize ) if( m_numTextSize != aOther.m_numTextSize )
return false; return false;
if( m_nameTextSize != other->m_nameTextSize ) if( m_nameTextSize != aOther.m_nameTextSize )
return false; return false;
if( m_alternates.size() != other->m_alternates.size() ) if( m_alternates.size() != aOther.m_alternates.size() )
return false; return false;
auto lhsItem = m_alternates.begin(); auto lhsItem = m_alternates.begin();
auto rhsItem = other->m_alternates.begin(); auto rhsItem = aOther.m_alternates.begin();
while( lhsItem != m_alternates.end() ) while( lhsItem != m_alternates.end() )
{ {
if( rhsItem == other->m_alternates.end() ) if( rhsItem == aOther.m_alternates.end() )
return false; return false;
const ALT& lhsAlt = lhsItem->second; const ALT& lhsAlt = lhsItem->second;
@ -2103,7 +2098,7 @@ bool SCH_PIN::operator==( const SCH_ITEM& aOther ) const
++rhsItem; ++rhsItem;
} }
if( rhsItem != other->m_alternates.end() ) if( rhsItem != aOther.m_alternates.end() )
return false; return false;
} }

View File

@ -285,8 +285,7 @@ public:
double Similarity( const SCH_ITEM& aOther ) const override; double Similarity( const SCH_ITEM& aOther ) const override;
bool operator==( const SCH_ITEM& aOther ) const override; bool operator==( const SCH_PIN& aOther ) const;
bool operator!=( const SCH_ITEM& aOther ) const { return !operator==( aOther ); }
bool operator<( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; } bool operator<( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; }
bool operator>( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; } bool operator>( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; }

View File

@ -2712,7 +2712,7 @@ bool SCH_SYMBOL::operator==( const SCH_ITEM& aOther ) const
for( unsigned i = 0; i < m_pins.size(); ++i ) for( unsigned i = 0; i < m_pins.size(); ++i )
{ {
if( !( *m_pins[i] == *symbol.m_pins[i] ) ) if( *m_pins[i] == *symbol.m_pins[i] )
return false; return false;
} }