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
This commit is contained in:
Seth Hillbrand 2020-01-04 15:05:57 -08:00
parent 6e5e453d0d
commit 77c60d9655
20 changed files with 26 additions and 911 deletions

View File

@ -110,7 +110,6 @@ add_library( singletop STATIC EXCLUDE_FROM_ALL
# as APIEXPORT
set( LIB_KICAD_SRCS
colors.cpp
dlist.cpp
string.cpp
)

View File

@ -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;
}

View File

@ -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 <dick@softplc.com>
* 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 <fctsys.h>
#include <dlist.h>
#include <base_struct.h>
// 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 && i<count; ++i, item = item->Next() )
{
if( i < count-1 )
{
wxASSERT( item->Next() );
}
wxASSERT( item->GetList() == this );
}
wxASSERT( item == NULL );
wxASSERT( i == count );
i = 0;
for( item = last; item && i<count; ++i, item = item->Back() )
{
if( i < count-1 )
{
wxASSERT( item->Back() );
}
}
wxASSERT( item == NULL );
wxASSERT( i == count );
// printf("list %p has %d items.\n", this, count );
}
#endif

View File

@ -36,7 +36,6 @@ class LINE_READER;
class OUTPUTFORMATTER;
class LIB_PART;
class PLOTTER;
class LIB_ITEM;
class LIB_PIN;
class MSG_PANEL_ITEM;

View File

@ -30,7 +30,6 @@
#include <eagle_parser.h>
#include <lib_item.h>
#include <geometry/seg.h>
#include <dlist.h>
#include <boost/ptr_container/ptr_map.hpp>

View File

@ -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();

View File

@ -46,7 +46,7 @@
#include <lib_polyline.h>
#include <lib_rectangle.h>
#include <lib_text.h>
#include <math/util.h> // for KiROUND
#include <math/util.h>
#include <plotter.h>
#include <sch_bitmap.h>
#include <sch_bus_entry.h>

View File

@ -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;

View File

@ -23,30 +23,32 @@
*/
#include <ee_actions.h>
#include <class_libentry.h>
#include <core/typeinfo.h>
#include <sch_item.h>
#include <ee_actions.h>
#include <ee_collectors.h>
#include <ee_selection_tool.h>
#include <sch_base_frame.h>
#include <sch_edit_frame.h>
#include <eeschema_id.h> // For MAX_SELECT_ITEM_IDS
#include <lib_edit_frame.h>
#include <lib_item.h>
#include <lib_view_frame.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_field.h>
#include <sch_line.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <view/view_group.h>
#include <math/util.h>
#include <menus_helpers.h>
#include <painter.h>
#include <preview_items/selection_area.h>
#include <sch_base_frame.h>
#include <sch_component.h>
#include <sch_edit_frame.h>
#include <sch_field.h>
#include <sch_item.h>
#include <sch_line.h>
#include <sch_sheet.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <tools/sch_line_wire_bus_tool.h>
#include <ee_collectors.h>
#include <painter.h>
#include <eeschema_id.h> // For MAX_SELECT_ITEM_IDS
#include <menus_helpers.h>
#include <math/util.h> // for KiROUND
#include <view/view.h>
#include <view/view_controls.h>
#include <view/view_group.h>
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<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
LIB_PART* start = static_cast<LIB_EDIT_FRAME*>( 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<EDA_ITEM*>( &item ) );
}
}
else
{

View File

@ -48,8 +48,6 @@ public:
GBR_SCREEN( const wxSize& aPageSizeIU );
~GBR_SCREEN();
GBR_SCREEN* Next() const { return static_cast<GBR_SCREEN*>( Pnext ); }
/**
* Function ClearUndoORRedoList
* virtual pure in BASE_SCREEN, so it must be defined here

View File

@ -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<GERBER_DRAW_ITEM> 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<GERBER_DRAW_ITEM*>( Pnext ); }
GERBER_DRAW_ITEM* Back() const { return static_cast<GERBER_DRAW_ITEM*>( Pback ); }
void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
const GBR_NETLIST_METADATA& GetNetAttributes() const { return m_netAttributes; }

View File

@ -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 )
*

View File

@ -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 );

View File

@ -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 <dlist.h>
#include <iterator>
template <class T>
class DLIST_ITERATOR : public std::iterator<std::bidirectional_iterator_tag, T>
{
private:
T m_obj;
using reference = typename DLIST_ITERATOR<T>::reference;
public:
explicit DLIST_ITERATOR<T>( T obj ) :
m_obj(obj) {}
DLIST_ITERATOR<T>& operator++()
{
m_obj = m_obj->Next(); return *this;
}
DLIST_ITERATOR<T>& operator--()
{
m_obj = m_obj->Prev(); return *this;
}
bool operator==( DLIST_ITERATOR<T> other ) const
{
return m_obj == other.m_obj;
}
bool operator!=( DLIST_ITERATOR<T> other ) const
{
return !(*this == other);
}
reference operator*()
{
return m_obj;
}
};
// helper object, used to convert a DLIST<T> to an iterator
template <class T>
class DLIST_ITERATOR_WRAPPER
{
public:
explicit DLIST_ITERATOR_WRAPPER<T> ( DLIST<T>& list ) :
m_list(list) {}
DLIST_ITERATOR<T*> begin()
{
return DLIST_ITERATOR<T*> ( m_list.GetFirst() );
}
DLIST_ITERATOR<T*> end()
{
return DLIST_ITERATOR<T*> ( nullptr );
}
unsigned int Size() const
{
return m_list.GetCount();
}
private:
DLIST<T>& m_list;
};
#endif

View File

@ -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 <dick@softplc.com>
* 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 <cstdio> // NULL definition.
#include <wx/defs.h> // 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 T>
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 );
}
//-----</ STL like functions >--------------------------------------
};
#endif // DLIST_H_

View File

@ -55,7 +55,6 @@ public:
~PCB_SCREEN();
PCB_SCREEN* Next() const { return static_cast<PCB_SCREEN*>( Pnext ); }
/* full undo redo management : */

View File

@ -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();

View File

@ -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.

View File

@ -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

View File

@ -1,132 +0,0 @@
#include <base_struct.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <deque>
#include <dlist.h>
#include <time.h>
#include <common.h>
#define TEST_NODES 100000000
//typedef std::vector<EDA_ITEM*> EDA_ITEMV;
//typedef std::deque<EDA_ITEM*> EDA_ITEMV;
typedef boost::ptr_vector<EDA_ITEM> 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<EDA_ITEM> 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; i<TEST_NODES; ++i )
{
v.push_back( new MY_ITEM( NOT_USED ) );
}
vAllocStop = GetRunningMicroSecs();
vIterateStart = vAllocStop;
for( EDA_ITEMV::const_iterator it = v.begin(); it != v.end(); ++it )
{
if( it->Type() == -22 )
{
printf( "never this\n" );
break;
}
}
vIterateStop = GetRunningMicroSecs();
#if 0
for( int i=0; i<TEST_NODES; ++i )
{
delete v[i];
}
#endif
v.clear();
dAllocStart = GetRunningMicroSecs();
for( int i=0; i<TEST_NODES; ++i )
{
dlist.PushBack( new MY_ITEM( NOT_USED ) );
}
dAllocStop = GetRunningMicroSecs();
dIterateStart = dAllocStop;
for( const EDA_ITEM* it = dlist; it; it = it->Next() )
{
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<TEST_NODES; ++i )
{
vec.push_back( new MY_ITEM( NOT_USED ) );
}
for( int i=0; i<TEST_NODES; ++i )
{
// delete vec[i];
}
vec.clear();
}