From 77c60d96553d5dadb23cfe77915781066a263979 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 4 Jan 2020 15:05:57 -0800 Subject: [PATCH] Remove the last vestiges of dlist It served us (mostly) well for more than a decade. It helped KiCad grow before the std:: came into decent shape or speed. It was a good little list. RIP DLIST 2008-2020 --- common/CMakeLists.txt | 1 - common/base_struct.cpp | 5 - common/dlist.cpp | 241 ------------------------ eeschema/lib_item.h | 1 - eeschema/sch_eagle_plugin.h | 1 - eeschema/sch_line.h | 3 - eeschema/sch_painter.cpp | 2 +- eeschema/schematic_undo_redo.cpp | 2 - eeschema/tools/ee_selection_tool.cpp | 55 +++--- gerbview/gbr_screen.h | 2 - gerbview/gerber_draw_item.h | 5 - include/base_struct.h | 43 ----- include/class_board_item.h | 4 +- include/core/iterators.h | 95 ---------- include/dlist.h | 262 --------------------------- include/pcb_screen.h | 1 - pcbnew/class_track.cpp | 62 ------- pcbnew/class_track.h | 10 - tools/CMakeLists.txt | 10 - tools/container_test.cpp | 132 -------------- 20 files changed, 26 insertions(+), 911 deletions(-) delete mode 100644 common/dlist.cpp delete mode 100644 include/core/iterators.h delete mode 100644 include/dlist.h delete mode 100644 tools/container_test.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 56d68fd74a..9ca2411b8d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -110,7 +110,6 @@ add_library( singletop STATIC EXCLUDE_FROM_ALL # as APIEXPORT set( LIB_KICAD_SRCS colors.cpp - dlist.cpp string.cpp ) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 1bb806b7da..f212476936 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -84,10 +84,7 @@ EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) void EDA_ITEM::initVars() { m_StructType = TYPE_NOT_INIT; - Pnext = NULL; // Linked list: Link (next struct) - Pback = NULL; // Linked list: Link (previous struct) m_Parent = NULL; // Linked list: Link (parent struct) - m_List = NULL; // I am not on any list yet m_Flags = 0; // flags for editions and other SetTimeStamp( 0 ); // Time stamp used for logical links m_Status = 0; @@ -228,8 +225,6 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) // A copy of an item cannot have the same time stamp as the original item. SetTimeStamp( GetNewTimeStamp() ); - // do not copy list related fields (Pnext, Pback, m_List) - return *this; } diff --git a/common/dlist.cpp b/common/dlist.cpp deleted file mode 100644 index 6c8d794141..0000000000 --- a/common/dlist.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2008 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2008 KiCad Developers, see change_log.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#include -#include -#include - -// verifies conditions for setting a parent list for an element, i.e. -// element either does not belong to any list or it already belongs to the same list -#define CHECK_OWNERSHIP(a) wxASSERT( !a->GetList() || a->GetList() == this ); - -/* Implement the class DHEAD from dlist.h */ - - -DHEAD::~DHEAD() -{ - if( meOwner ) - DeleteAll(); -} - - -void DHEAD::DeleteAll() -{ - wxCHECK( meOwner, /*void*/ ); // only owning lists may delete the contents - EDA_ITEM* next; - EDA_ITEM* item = first; - - while( item ) - { - next = item->Next(); - delete item; // virtual destructor, class specific - item = next; - } - - first = 0; - last = 0; - count = 0; -} - - -void DHEAD::append( EDA_ITEM* aNewElement ) -{ - wxCHECK( aNewElement, /*void*/ ); - - if( first ) // list is not empty, first is not touched - { - wxASSERT( count > 0 ); - wxCHECK( last, /*void*/ ); // 'first' is non-null, so 'last' should be non-null too - - aNewElement->SetNext( 0 ); - aNewElement->SetBack( last ); - - wxASSERT( !last->Next() ); // the last element should point to nullptr - last->SetNext( aNewElement ); - last = aNewElement; - } - else // list is empty, first and last are changed - { - wxASSERT( count == 0 ); - wxASSERT( !last ); // 'first' is null, then 'last' should be too - aNewElement->SetNext( 0 ); - aNewElement->SetBack( 0 ); - - first = aNewElement; - last = aNewElement; - } - - CHECK_OWNERSHIP( aNewElement ); - aNewElement->SetList( this ); - - ++count; -} - - -void DHEAD::append( DHEAD& aList ) -{ - if( aList.first ) - { - // Change the item's list to me. - for( EDA_ITEM* item = aList.first; item; item = item->Next() ) - { - wxASSERT( item->GetList() == &aList ); - item->SetList( this ); - } - - if( first ) // this list is not empty, set last item's next to the first item in aList - { - wxCHECK_RET( last != NULL, wxT( "Last list element not set." ) ); - - last->SetNext( aList.first ); - aList.first->SetBack( last ); - last = aList.last; - } - else // this list is empty, first and last are same as aList - { - first = aList.first; - last = aList.last; - } - - count += aList.count; - - aList.count = 0; - aList.first = NULL; - aList.last = NULL; - } -} - - -void DHEAD::insert( EDA_ITEM* aNewElement, EDA_ITEM* aAfterMe ) -{ - wxCHECK( aNewElement, /*void*/ ); - - if( !aAfterMe ) - append( aNewElement ); - else - { - wxCHECK( aAfterMe->GetList() == this, /*void*/ ); - - // the list cannot be empty if aAfterMe is supposedly on the list - wxASSERT( first && last && count > 0 ); - - if( first == aAfterMe ) - { - aAfterMe->SetBack( aNewElement ); - - aNewElement->SetBack( 0 ); // first in list does not point back - aNewElement->SetNext( aAfterMe ); - - first = aNewElement; - } - else - { - EDA_ITEM* oldBack = aAfterMe->Back(); - - aAfterMe->SetBack( aNewElement ); - - aNewElement->SetBack( oldBack ); - aNewElement->SetNext( aAfterMe ); - - oldBack->SetNext( aNewElement ); - } - - CHECK_OWNERSHIP( aNewElement ); - aNewElement->SetList( this ); - - ++count; - } -} - - -void DHEAD::remove( EDA_ITEM* aElement ) -{ - wxCHECK( aElement && aElement->GetList() == this, /*void*/ ); - - if( aElement->Next() ) - { - aElement->Next()->SetBack( aElement->Back() ); - } - else // element being removed is last - { - wxASSERT( last == aElement ); - last = aElement->Back(); - } - - if( aElement->Back() ) - { - aElement->Back()->SetNext( aElement->Next() ); - } - else // element being removed is first - { - wxASSERT( first == aElement ); - first = aElement->Next(); - } - - aElement->SetBack( 0 ); - aElement->SetNext( 0 ); - aElement->SetList( 0 ); - - --count; - wxASSERT( ( first && last ) || count == 0 ); -} - -#if defined(DEBUG) - -void DHEAD::VerifyListIntegrity() -{ - EDA_ITEM* item; - unsigned i = 0; - - for( item = first; item && iNext() ) - { - if( i < count-1 ) - { - wxASSERT( item->Next() ); - } - - wxASSERT( item->GetList() == this ); - } - - wxASSERT( item == NULL ); - wxASSERT( i == count ); - - i = 0; - for( item = last; item && iBack() ) - { - if( i < count-1 ) - { - wxASSERT( item->Back() ); - } - } - - wxASSERT( item == NULL ); - wxASSERT( i == count ); - - // printf("list %p has %d items.\n", this, count ); -} - -#endif - diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index 83230e00a5..348316244d 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -36,7 +36,6 @@ class LINE_READER; class OUTPUTFORMATTER; class LIB_PART; class PLOTTER; -class LIB_ITEM; class LIB_PIN; class MSG_PANEL_ITEM; diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h index 60e044cb22..46d31dfdb8 100644 --- a/eeschema/sch_eagle_plugin.h +++ b/eeschema/sch_eagle_plugin.h @@ -30,7 +30,6 @@ #include #include #include -#include #include diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 238b52fca8..ebe7be1440 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -59,9 +59,6 @@ public: ~SCH_LINE() { } - SCH_LINE* Next() const { return (SCH_LINE*) Pnext; } - SCH_LINE* Back() const { return (SCH_LINE*) Pback; } - static inline bool ClassOf( const EDA_ITEM* aItem ) { return aItem && SCH_LINE_T == aItem->Type(); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 73b1796242..f7e33b3aea 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -46,7 +46,7 @@ #include #include #include -#include // for KiROUND +#include #include #include #include diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index b20db461f5..3177187001 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -332,8 +332,6 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed break; case UR_EXCHANGE_T: - alt_item->SetNext( nullptr ); - alt_item->SetBack( nullptr ); aList->SetPickedItem( alt_item, (unsigned) ii ); aList->SetPickedItemLink( item, (unsigned) ii ); item = alt_item; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 9affdc975d..c491a2c69c 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -23,30 +23,32 @@ */ -#include +#include #include -#include +#include +#include #include -#include -#include +#include // For MAX_SELECT_ITEM_IDS #include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include // For MAX_SELECT_ITEM_IDS -#include -#include // for KiROUND +#include +#include +#include SELECTION_CONDITION EE_CONDITIONS::Empty = [] (const SELECTION& aSelection ) @@ -970,22 +972,13 @@ void EE_SELECTION_TOOL::RebuildSelection() if( m_isLibEdit ) { - EDA_ITEM* start = nullptr; - start = static_cast( m_frame )->GetCurPart(); + LIB_PART* start = static_cast( m_frame )->GetCurPart(); - INSPECTOR_FUNC inspector = [&]( EDA_ITEM* item, void* testData ) { - // If the field and component are selected, only use the component - if( item->IsSelected() - && !( item->Type() == SCH_FIELD_T && item->GetParent() - && item->GetParent()->IsSelected() ) ) - { - select( item ); - } - - return SEARCH_RESULT::CONTINUE; - }; - - EDA_ITEM::IterateForward( start, inspector, nullptr, EE_COLLECTOR::AllItems ); + for( auto& item : start->GetDrawItems() ) + { + if( item.IsSelected() ) + select( static_cast( &item ) ); + } } else { diff --git a/gerbview/gbr_screen.h b/gerbview/gbr_screen.h index 8636a75c03..ca06053d29 100644 --- a/gerbview/gbr_screen.h +++ b/gerbview/gbr_screen.h @@ -48,8 +48,6 @@ public: GBR_SCREEN( const wxSize& aPageSizeIU ); ~GBR_SCREEN(); - GBR_SCREEN* Next() const { return static_cast( Pnext ); } - /** * Function ClearUndoORRedoList * virtual pure in BASE_SCREEN, so it must be defined here diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index 9a12a13025..3807fbb0e9 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -70,8 +70,6 @@ class GERBER_DRAW_ITEM : public EDA_ITEM // make SetNext() and SetBack() private so that they may not be called from anywhere. // list management is done on GERBER_DRAW_ITEMs using DLIST only. private: - void SetNext( EDA_ITEM* aNext ) { Pnext = aNext; } - void SetBack( EDA_ITEM* aBack ) { Pback = aBack; } public: @@ -123,9 +121,6 @@ public: GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams ); ~GERBER_DRAW_ITEM(); - GERBER_DRAW_ITEM* Next() const { return static_cast( Pnext ); } - GERBER_DRAW_ITEM* Back() const { return static_cast( Pback ); } - void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes ); const GBR_NETLIST_METADATA& GetNetAttributes() const { return m_netAttributes; } diff --git a/include/base_struct.h b/include/base_struct.h index 3df332604b..a670b066a5 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -80,7 +80,6 @@ class wxFindReplaceData; class EDA_ITEM; class EDA_DRAW_FRAME; class EDA_RECT; -class DHEAD; class MSG_PANEL_ITEM; @@ -174,9 +173,6 @@ private: STATUS_FLAGS m_Status; protected: - EDA_ITEM* Pnext; ///< next in linked list - EDA_ITEM* Pback; ///< previous in linked list - DHEAD* m_List; ///< which DLIST I am on. EDA_ITEM* m_Parent; ///< Linked list: Link (parent struct) timestamp_t m_TimeStamp; ///< Time stamp used for logical links @@ -216,15 +212,8 @@ public: void SetTimeStamp( timestamp_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; } timestamp_t GetTimeStamp() const { return m_TimeStamp; } - EDA_ITEM* Next() const { return Pnext; } - EDA_ITEM* Back() const { return Pback; } EDA_ITEM* GetParent() const { return m_Parent; } - DHEAD* GetList() const { return m_List; } - - void SetNext( EDA_ITEM* aNext ) { Pnext = aNext; } - void SetBack( EDA_ITEM* aBack ) { Pback = aBack; } void SetParent( EDA_ITEM* aParent ) { m_Parent = aParent; } - void SetList( DHEAD* aList ) { m_List = aList; } inline bool IsNew() const { return m_Flags & IS_NEW; } inline bool IsModified() const { return m_Flags & IS_CHANGED; } @@ -399,38 +388,6 @@ public: */ virtual SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ); - /** - * Function IterateForward - * walks through the object tree calling the inspector() on each object - * type requested in scanTypes. - * - * @param listStart The first in a list of EDA_ITEMs to iterate over. - * @param inspector Is an INSPECTOR to call on each object that is one of - * the requested scanTypes. - * @param testData Is an aid to testFunc, and should be sufficient to allow - * it to fully determine if an item meets the match criteria, - * but it may also be used to collect output. - * @param scanTypes A KICAD_T array that is EOT terminated, and provides both - * the order and interest level of of the types of objects to - * be iterated over. - * @return SEARCH_RESULT SEARCH_QUIT if the called INSPECTOR returned - * SEARCH_QUIT, else SCAN_CONTINUE; - */ - static SEARCH_RESULT IterateForward( EDA_ITEM* listStart, - INSPECTOR inspector, - void* testData, - const KICAD_T scanTypes[] ) - - { - for( EDA_ITEM* p = listStart; p; p = p->Pnext ) - { - if( SEARCH_RESULT::QUIT == p->Visit( inspector, testData, scanTypes ) ) - return SEARCH_RESULT::QUIT; - } - - return SEARCH_RESULT::CONTINUE; - } - /** * @copydoc SEARCH_RESULT IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) * diff --git a/include/class_board_item.h b/include/class_board_item.h index edec1303cc..85fe68fa7c 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -162,9 +162,7 @@ public: * Swap data between aItem and aImage. * aItem and aImage should have the same type * Used in undo redo command to swap values between an item and its copy - * Only values like layer, size .. which are modified by editing are swapped, - * not the pointers like - * Pnext and Pback because aItem is not changed in the linked list + * Only values like layer, size .. which are modified by editing are swapped * @param aImage = the item image which contains data to swap */ virtual void SwapData( BOARD_ITEM* aImage ); diff --git a/include/core/iterators.h b/include/core/iterators.h deleted file mode 100644 index 298bd3361a..0000000000 --- a/include/core/iterators.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 CERN - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __ITERATORS_H -#define __ITERATORS_H - -#include -#include - -template -class DLIST_ITERATOR : public std::iterator -{ -private: - T m_obj; - - using reference = typename DLIST_ITERATOR::reference; - -public: - explicit DLIST_ITERATOR( T obj ) : - m_obj(obj) {} - - DLIST_ITERATOR& operator++() - { - m_obj = m_obj->Next(); return *this; - } - - DLIST_ITERATOR& operator--() - { - m_obj = m_obj->Prev(); return *this; - } - - bool operator==( DLIST_ITERATOR other ) const - { - return m_obj == other.m_obj; - } - - bool operator!=( DLIST_ITERATOR other ) const - { - return !(*this == other); - } - - reference operator*() - { - return m_obj; - } -}; - -// helper object, used to convert a DLIST to an iterator -template -class DLIST_ITERATOR_WRAPPER -{ -public: - explicit DLIST_ITERATOR_WRAPPER ( DLIST& list ) : - m_list(list) {} - - DLIST_ITERATOR begin() - { - return DLIST_ITERATOR ( m_list.GetFirst() ); - } - - DLIST_ITERATOR end() - { - return DLIST_ITERATOR ( nullptr ); - } - - unsigned int Size() const - { - return m_list.GetCount(); - } - -private: - DLIST& m_list; -}; - -#endif diff --git a/include/dlist.h b/include/dlist.h deleted file mode 100644 index 24b3f3ca6d..0000000000 --- a/include/dlist.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * This program source code file is part of KICAD, a free EDA CAD application. - * - * Copyright (C) 2008 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2008 Kicad Developers, see change_log.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#ifndef DLIST_H_ -#define DLIST_H_ - - -#include // NULL definition. -#include // wxDEPRECATED_MSG macro - -class EDA_ITEM; - - -/** - * Class DHEAD - * is only for use by template class DLIST, use that instead. - */ -class DHEAD -{ -protected: - EDA_ITEM* first; ///< first element in list, or NULL if list empty - EDA_ITEM* last; ///< last elment in list, or NULL if empty - unsigned count; ///< how many elements are in the list, automatically maintained. - bool meOwner; ///< I must delete the objects I hold in my destructor - - /** - * Constructor DHEAD - * is protected so that a DHEAD can only be instantiated from within a - * DLIST template. - */ - DHEAD() : - first(0), - last(0), - count(0), - meOwner(true) - { - } - - ~DHEAD(); - - /** - * Function append - * adds \a aNewElement to the end of the list. - * @param aNewElement The element to insert. - */ - void append( EDA_ITEM* aNewElement ); - - /** - * Function append - * adds \a aList to the end of the list. - * @param aList The list to aList. - */ - void append( DHEAD& aList ); - - /** - * Function insert - * puts \a aNewElement just in front of \a aElementAfterMe in the list sequence. - * If \a aElementAfterMe is NULL, then simply append(). - * @param aNewElement The element to insert. - * @param aElementAfterMe The element to insert \a aNewElement before, - * if NULL then append \a aNewElement onto end of list. - */ - void insert( EDA_ITEM* aNewElement, EDA_ITEM* aElementAfterMe ); - - /** - * Function insert - * puts \a aNewElement in front of list sequence. - * @param aNewElement The element to insert. - */ - void insert( EDA_ITEM* aNewElement ) - { - insert( aNewElement, first ); - } - - /** - * Function remove - * removes \a aElement from the list, but does not delete it. - * @param aElement The element to remove. - */ - void remove( EDA_ITEM* aElement ); - - -public: - - /** - * Function DeleteAll - * deletes all items on the list and leaves the list empty. The destructor - * for each item is called. - */ - void DeleteAll(); - - /** - * Function SetOwnership - * controls whether the list owns the objects and is responsible for - * deleteing their memory at time of this object's destruction. - */ - void SetOwnership( bool Iown ) { meOwner = Iown; } - - - /** - * Function GetCount - * returns the number of elements in the list. - */ - unsigned GetCount() const { return count; } - -#if defined(DEBUG) - void VerifyListIntegrity(); -#endif -}; - - -/** - * Class DLIST - * is the head of a doubly linked list. It contains pointers to the first - * and last elements in a doubly linked list. The elements in the list must - * be of class T or derived from T, and T must be derived from EDA_ITEM. - * @see DHEAD for additional public functions. - */ -template -class -#if !defined( EESCHEMA ) - wxDEPRECATED_MSG( "DLIST is deprecated, do not use in new code" ) -#endif -DLIST : public DHEAD -{ -public: - - /** - * operator T* - * is a casting operator that returns \a GetFirst(), a T* - */ - operator T* () const { return GetFirst(); } - - /** - * operator -> - * is a dereferencing operator that returns \a GetFirst(), a T* - */ - T* operator -> () const { return GetFirst(); } - - /** - * Function GetFirst - * returns the first T* in the list without removing it, or NULL if - * the list is empty. - */ - T* GetFirst() const { return (T*) first; } - - /** - * Function GetLast - * returns the last T* in the list without removing it, - * or NULL if the list is empty. - */ - T* GetLast() const { return (T*) last; } - - /** - * Function Append - * adds \a aNewElement to the end of the list. - * @param aNewElement The element to insert. - */ - void Append( T* aNewElement ) - { - append( aNewElement ); - } - - /** - * Function Append - * adds \a aList to the end of the list. - * @param aList The list to append to the end of the list. - */ - void Append( DLIST& aList ) - { - append( aList ); - } - - /** - * Function Insert - * puts \a aNewElement just in front of \a aElementAfterMe in the list sequence. - * If aElementAfterMe is NULL, then simply Append() - * @param aNewElement The element to insert. - * @param aElementAfterMe The element to insert \a aNewElement before, - * if NULL then append \a aNewElement onto end of list. - */ - void Insert( T* aNewElement, T* aElementAfterMe ) - { - insert( aNewElement, aElementAfterMe ); - } - - /** - * Function Remove - * removes \a aElement from the list, but does not delete it. - * @param aElement The element to remove from the list. - * @return T* - the removed element, so you can easily delete it upon return. - */ - T* Remove( T* aElement ) - { - remove( aElement ); - return aElement; - } - - //-----< STL like functions >--------------------------------------- - T* begin() const { return GetFirst(); } - T* end() const { return GetLast(); } - - T* PopFront() - { - if( GetFirst() ) - return Remove( GetFirst() ); - return NULL; - } - - T* PopBack() - { - if( GetLast() ) - return Remove( GetLast() ); - return NULL; - } - - /** - * Function PushFront - * puts aNewElement at front of list sequence. - * @param aNewElement The element to insert at the front of the list. - */ - void PushFront( T* aNewElement ) - { - insert( aNewElement ); - } - - /** - * Function PushBack - * puts aNewElement at the end of the list sequence. - * @param aNewElement The element to push to the end of the list. - */ - void PushBack( T* aNewElement ) - { - append( aNewElement ); - } - - //------------------------------------------- -}; - -#endif // DLIST_H_ diff --git a/include/pcb_screen.h b/include/pcb_screen.h index 069cee3799..da03e499ac 100644 --- a/include/pcb_screen.h +++ b/include/pcb_screen.h @@ -55,7 +55,6 @@ public: ~PCB_SCREEN(); - PCB_SCREEN* Next() const { return static_cast( Pnext ); } /* full undo redo management : */ diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index e8b4a10512..c6063bdc66 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -390,68 +390,6 @@ void VIA::SanitizeLayers() } -TRACK* TRACK::GetStartNetCode( int NetCode ) -{ - TRACK* Track = this; - int ii = 0; - - if( NetCode == -1 ) - NetCode = GetNetCode(); - - while( Track != NULL ) - { - if( Track->GetNetCode() > NetCode ) - break; - - if( Track->GetNetCode() == NetCode ) - { - ii++; - break; - } - - Track = (TRACK*) Track->Pnext; - } - - if( ii ) - return Track; - else - return NULL; -} - - -TRACK* TRACK::GetEndNetCode( int NetCode ) -{ - TRACK* NextS, * Track = this; - int ii = 0; - - if( Track == NULL ) - return NULL; - - if( NetCode == -1 ) - NetCode = GetNetCode(); - - while( Track != NULL ) - { - NextS = (TRACK*) Track->Pnext; - - if( Track->GetNetCode() == NetCode ) - ii++; - - if( NextS == NULL ) - break; - - if( NextS->GetNetCode() > NetCode ) - break; - - Track = NextS; - } - - if( ii ) - return Track; - else - return NULL; -} - void TRACK::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { BOARD* brd = GetBoard(); diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index ba01eb3229..f3a95cb101 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -131,16 +131,6 @@ public: return SetState( TRACK_LOCKED, aLocked ); } - /* Search (within the track linked list) the first segment matching the netcode - * ( the linked list is always sorted by net codes ) - */ - TRACK* GetStartNetCode( int NetCode ); - - /* Search (within the track linked list) the last segment matching the netcode - * ( the linked list is always sorted by net codes ) - */ - TRACK* GetEndNetCode( int NetCode ); - /** * Function GetLength * returns the length of the track using the hypotenuse calculation. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 2c9587bbf2..c83216f9f6 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -7,16 +7,6 @@ include_directories( ${CMAKE_BINARY_DIR} ) - -add_executable( container_test - EXCLUDE_FROM_ALL - container_test.cpp - ) -target_link_libraries( container_test - common - ${wxWidgets_LIBRARIES} - ) - add_executable( test-nm-biu-to-ascii-mm-round-tripping EXCLUDE_FROM_ALL test-nm-biu-to-ascii-mm-round-tripping.cpp diff --git a/tools/container_test.cpp b/tools/container_test.cpp deleted file mode 100644 index 3b65dad7c4..0000000000 --- a/tools/container_test.cpp +++ /dev/null @@ -1,132 +0,0 @@ - -#include -#include -#include -#include -#include -#include - -#define TEST_NODES 100000000 - - -//typedef std::vector EDA_ITEMV; -//typedef std::deque EDA_ITEMV; -typedef boost::ptr_vector EDA_ITEMV; - -class MY_ITEM : public EDA_ITEM -{ -public: - - MY_ITEM( KICAD_T id ) : - EDA_ITEM( id ) - {} - - -#if defined(DEBUG) - void Show( int nestLevel, std::ostream& os ) const - { - ShowDummy( os ); - } -#endif -}; - - -void heap_warm_up(); - -int main( int argc, char** argv ) -{ - EDA_ITEMV v; - DLIST dlist; - - unsigned vAllocStart; - unsigned vAllocStop; - unsigned vIterateStart; - unsigned vIterateStop; - - unsigned dAllocStart; - unsigned dAllocStop; - unsigned dIterateStart; - unsigned dIterateStop; - - heap_warm_up(); - - vAllocStart = GetRunningMicroSecs(); - - for( int i=0; iType() == -22 ) - { - printf( "never this\n" ); - break; - } - } - - vIterateStop = GetRunningMicroSecs(); - -#if 0 - for( int i=0; iNext() ) - { - if( it->Type() == -22 ) - { - printf( "never this\n" ); - break; - } - } - - dIterateStop = GetRunningMicroSecs(); - - printf( "vector alloc: %u usecs iterate: %u usecs\n", - vAllocStop - vAllocStart, - vIterateStop - vIterateStart ); - - printf( "dlist alloc: %u usecs iterate: %u usecs\n", - dAllocStop - dAllocStart, - dIterateStop - dIterateStart ); -} - - -void heap_warm_up() -{ - // dry run allocate enough object for process to obtain all memory needed - - EDA_ITEMV vec; - - for( int i=0; i