KiCad PCB EDA Suite
Loading...
Searching...
No Matches
alg Namespace Reference

Functions

template<typename _Type , typename _Function >
void run_on_pair (std::pair< _Type, _Type > &__pair, _Function __f)
 Apply a function to the first and second element of a std::pair. More...
 
template<typename _InputIterator , typename _Function >
void adjacent_pairs (_InputIterator __first, _InputIterator __last, _Function __f)
 Apply a function to every sequential pair of elements of a sequence. More...
 
template<typename _InputIterator , typename _Function >
void for_all_pairs (_InputIterator __first, _InputIterator __last, _Function __f)
 Apply a function to every possible pair of elements of a sequence. More...
 
template<class _Container , typename _Value >
bool contains (const _Container &__container, _Value __value)
 Returns true if the container contains the given value. More...
 
template<typename _Type , typename _Value >
bool pair_contains (const std::pair< _Type, _Type > __pair, _Value __value)
 Returns true if either of the elements in an std::pair contains the given value. More...
 
template<class T >
bool within_wrapped_range (T __val, T __minval, T __maxval, T __wrap)
 Test if __val lies within __minval and __maxval in a wrapped range. More...
 
template<class _Container , typename _Value >
void delete_matching (_Container &__c, _Value __value)
 Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything). More...
 
template<class _Container , class _Function >
void delete_if (_Container &__c, _Function &&__f)
 Deletes all values from __c for which __f returns true. More...
 
template<class _Container >
void remove_duplicates (_Container &__c)
 Deletes all duplicate values from __c. More...
 
template<class _Container , class _Function >
void remove_duplicates (_Container &__c, _Function &&__f)
 
template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
bool signbit (T v)
 Integral version of std::signbit that works all compilers. More...
 
template<typename T >
clamp (T min, T value, T max)
 
template<class _Container >
size_t longest_common_subset (const _Container &__c1, const _Container &__c2)
 Returns the length of the longest common subset of values between two containers. More...
 

Function Documentation

◆ adjacent_pairs()

template<typename _InputIterator , typename _Function >
void alg::adjacent_pairs ( _InputIterator  __first,
_InputIterator  __last,
_Function  __f 
)

Apply a function to every sequential pair of elements of a sequence.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__fA unary function object.

Applies the function object __f to each sequential pair of elements in the range [first,last). __f must not modify the order of the sequence. If __f has a return value it is ignored.

Definition at line 62 of file kicad_algo.h.

◆ clamp()

◆ contains()

template<class _Container , typename _Value >
bool alg::contains ( const _Container &  __container,
_Value  __value 
)

Returns true if the container contains the given value.

Definition at line 100 of file kicad_algo.h.

Referenced by PROJECT_TREE_PANE::addItemToProjectTree(), SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), FP_TREE_MODEL_ADAPTER::AddLibraries(), BOARD::AddListener(), SCHEMATIC::AddListener(), TEARDROP_MANAGER::AddTeardropsOnTracks(), CVPCB_MAINFRAME::BuildLibrariesList(), FOOTPRINT::CheckShortingPads(), CN_CLUSTER::Contains(), PNS::ITEM_SET::Contains(), PNS::LINK_HOLDER::ContainsLink(), SCH_IO_LTSPICE_PARSER::CreateKicadSYMBOLs(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), SCH_EDIT_TOOL::DoDelete(), TITLE_BLOCK::GetContextualTextVars(), SCH_SHEET::GetContextualTextVars(), SCHEMATIC::GetContextualTextVars(), BOARD::GetContextualTextVars(), DRC_ITEMS_PROVIDER::GetCount(), PANEL_SETUP_LAYERS::getNonRemovableLayers(), PANEL_SETUP_LAYERS::getRemovedLayersWithItems(), WX_GRID::GetUnitValue(), SYMBOL_EDIT_FRAME::HardRedraw(), DIALOG_EXPORT_SVG::initDialog(), TOOL_MANAGER::isActive(), CONNECTIVITY_DATA::IsConnectedOnLayer(), isKeyModifierOnly(), isKeySpecialCode(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), SCH_COMMIT::makeImage(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddLayer(), WX_GRID::onCellEditorHidden(), WX_GRID::onCellEditorShown(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER(), PCB_IO_KICAD_SEXPR_PARSER::parseSetup(), PNS::TOOL_BASE::pickSingleItem(), PROJECT::PinLibrary(), PCB_CONTROL::placeBoardItems(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), SELECTION_TOOL::RemoveItemsFromSel(), TEARDROP_MANAGER::RemoveTeardrops(), SAVE_AS_DIALOG::SAVE_AS_DIALOG(), EDA_DRAW_FRAME::saveCanvasTypeSetting(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), DRC_ITEMS_PROVIDER::SetSeverities(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::UpdateConflicts(), DIALOG_CHANGE_SYMBOLS::updateFieldsList(), LIB_TREE::updateRecentSearchMenu(), and TEARDROP_MANAGER::UpdateTeardrops().

◆ delete_if()

◆ delete_matching()

template<class _Container , typename _Value >
void alg::delete_matching ( _Container &  __c,
_Value  __value 
)

◆ for_all_pairs()

template<typename _InputIterator , typename _Function >
void alg::for_all_pairs ( _InputIterator  __first,
_InputIterator  __last,
_Function  __f 
)

Apply a function to every possible pair of elements of a sequence.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__fA unary function object.

Applies the function object __f to every possible pair of elements in the range [first,last). __f must not modify the order of the sequence. If __f has a return value it is ignored.

Definition at line 84 of file kicad_algo.h.

Referenced by SCH_EDIT_FRAME::DeleteJunction(), and SCH_EDIT_FRAME::SchematicCleanUp().

◆ longest_common_subset()

template<class _Container >
size_t alg::longest_common_subset ( const _Container &  __c1,
const _Container &  __c2 
)

Returns the length of the longest common subset of values between two containers.

Definition at line 214 of file kicad_algo.h.

Referenced by ZONE::Similarity(), and EDA_SHAPE::Similarity().

◆ pair_contains()

template<typename _Type , typename _Value >
bool alg::pair_contains ( const std::pair< _Type, _Type >  __pair,
_Value  __value 
)

Returns true if either of the elements in an std::pair contains the given value.

Parameters
__pairA pair of elements (both elements must be the same type).
__valueA value to test
Returns
true if __value is contained in __pair

Definition at line 113 of file kicad_algo.h.

Referenced by SHAPE_LINE_CHAIN::NextShape().

◆ remove_duplicates() [1/2]

template<class _Container >
void alg::remove_duplicates ( _Container &  __c)

◆ remove_duplicates() [2/2]

template<class _Container , class _Function >
void alg::remove_duplicates ( _Container &  __c,
_Function &&  __f 
)

Definition at line 189 of file kicad_algo.h.

◆ run_on_pair()

template<typename _Type , typename _Function >
void alg::run_on_pair ( std::pair< _Type, _Type > &  __pair,
_Function  __f 
)

Apply a function to the first and second element of a std::pair.

Parameters
__pairA pair of elements (both elements must be the same type).
__fA unary function object.

Applies the function object __f to __pair.first and __pair.second If __f has a return value it is ignored.

Definition at line 45 of file kicad_algo.h.

Referenced by SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::convertArc(), SHAPE_LINE_CHAIN::Insert(), SHAPE_LINE_CHAIN::Remove(), SHAPE_LINE_CHAIN::Replace(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::SetPoint(), and SHAPE_LINE_CHAIN::splitArc().

◆ signbit()

template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
bool alg::signbit ( v)

Integral version of std::signbit that works all compilers.

Definition at line 198 of file kicad_algo.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), and SCH_MOVE_TOOL::doMoveSelection().

◆ within_wrapped_range()

template<class T >
bool alg::within_wrapped_range ( __val,
__minval,
__maxval,
__wrap 
)

Test if __val lies within __minval and __maxval in a wrapped range.

Parameters
__valA value to test
__minvalLowest permissible value within the wrapped range
__maxvalHighest permissible value within the wrapped range
__wrapValue at which the range wraps around itself (must be positive)
Returns
true if __val lies in the wrapped range

Definition at line 129 of file kicad_algo.h.