/*! \file kbool/include/kbool/_lnk_itr.cpp \author Probably Klaas Holwerda Copyright: 2001-2004 (C) Probably Klaas Holwerda Licence: wxWidgets Licence RCS-ID: $Id: _lnk_itr.cpp,v 1.1 2005/05/24 19:13:36 titato Exp $ */ #ifdef __GNUG__ #pragma implementation #endif #ifdef __UNIX__ #include "kbool/include/_lnk_itr.h" #endif //======================================================================= // implementation class LinkBaseIter //======================================================================= template TDLI::TDLI(DL_List* newlist):DL_Iter(newlist) { } template TDLI::TDLI(DL_Iter* otheriter):DL_Iter(otheriter) { } template TDLI::TDLI():DL_Iter() { } // destructor TDLI template TDLI::~TDLI() { } template void TDLI::delete_all() { DL_Node* node; Type* obj; for (int i=0; i< NB; i++) { node = HD; HD = node->_next; obj=(Type*)(node->_item); delete obj; delete node; } NB=0; //reset memory used (no lost pointers) TL=RT; _current=RT; } template void TDLI::foreach_f(void (*fp) (Type* item) ) { DL_Iter::foreach_f( (void (*)(void*))fp); //call fp for each item } template void TDLI::foreach_mf(void (Type::*mfp) ()) { DL_Node* node=HD; //can be 0 if empty Type* obj; for(int i=0; i< NB; i++) { obj=(Type*)(node->_item); (obj->*mfp)(); node=node->_next; } } template void TDLI::takeover(DL_List* otherlist) { DL_Iter::takeover( (DL_List*) otherlist); } template void TDLI::takeover(TDLI* otheriter) { DL_Iter::takeover( (DL_Iter*) otheriter); } template void TDLI::takeover(TDLI* otheriter,int maxcount) { DL_Iter::takeover( (DL_Iter*) otheriter,maxcount); } // is item element of the list? template bool TDLI::has(Type* otheritem) { return DL_Iter::has( (void*) otheritem); } // goto to item template bool TDLI::toitem(Type* item) { return DL_Iter::toitem( (void*) item); } // get current item template Type* TDLI::item() { return (Type*) DL_Iter::item(); } template void TDLI::insend(Type* newitem) { DL_Iter::insend( (void*) newitem); } template void TDLI::insbegin(Type* newitem) { DL_Iter::insbegin( (void*) newitem); } template void TDLI::insbefore(Type* newitem) { DL_Iter::insbefore( (void*) newitem); } template void TDLI::insafter(Type* newitem) { DL_Iter::insafter( (void*) newitem); } template void TDLI::insend_unsave(Type* newitem) { short int iterbackup=_list->_iterlevel; _list->_iterlevel=0; DL_Iter::insend( (void*) newitem); _list->_iterlevel=iterbackup; } template void TDLI::insbegin_unsave(Type* newitem) { short int iterbackup=_list->_iterlevel; _list->_iterlevel=0; DL_Iter::insbegin( (void*) newitem); _list->_iterlevel=iterbackup; } template void TDLI::insbefore_unsave(Type* newitem) { short int iterbackup=_list->_iterlevel; _list->_iterlevel=0; DL_Iter::insbefore( (void*) newitem); _list->_iterlevel=iterbackup; } template void TDLI::insafter_unsave(Type* newitem) { short int iterbackup=_list->_iterlevel; _list->_iterlevel=0; DL_Iter::insafter( (void*) newitem); _list->_iterlevel=iterbackup; } template void TDLI::mergesort(int (*f)(Type* a,Type* b)) { DL_Iter::mergesort( (int (*)(void*,void*)) f); } template int TDLI::cocktailsort(int (*f)(Type* a,Type* b), bool (*f2)(Type* c,Type* d)) { return DL_Iter::cocktailsort( (int (*)(void*,void*)) f,( bool(*)(void*,void*)) f2); } template TDLISort::TDLISort(DL_List* lista, int (*newfunc)(void*,void*)) :DL_SortIter(lista, newfunc) { } template TDLISort::~TDLISort() { } template void TDLISort::delete_all() { DL_Node* node; Type* obj; for (int i=0; i< NB; i++) { node = HD; HD = node->_next; obj=(Type*)(node->_item); delete obj; delete node; } NB=0; //reset memory used (no lost pointers) TL=RT; _current=RT; } // is item element of the list? template bool TDLISort::has(Type* otheritem) { return DL_Iter::has( (void*) otheritem); } // goto to item template bool TDLISort::toitem(Type* item) { return DL_Iter::toitem( (void*) item); } // get current item template Type* TDLISort::item() { return (Type*) DL_Iter::item(); } template TDLIStack::TDLIStack(DL_List* newlist):DL_StackIter(newlist) { } // destructor TDLI template TDLIStack::~TDLIStack() { } // plaats nieuw item op stack template void TDLIStack::push(Type* newitem) { DL_StackIter::push((Type*) newitem); } // haal bovenste item van stack template Type* TDLIStack::pop() { return (Type*) DL_StackIter::pop(); }