void Liste::add(void *obj, int index){ if(index < 0){ index = (_len + 1) + index; } if(index < 0 || index > _len){ //TODO TROW ERR cout << "ERROR _getItem index out of range" << endl; return; } if(index == 0){ //if its the first item pushFirst(obj); } else if(index == _len) { //if its the last item pushLast(obj); } else { //if its not first or last ListeItem *f = _getItem(index); ListeItem *b = f->_back; ListeItem *newL = new ListeItem(b, f, obj); b->_front = newL; f->_back = newL; _len++; } }
void Liste::remove(int index){ if(index < 0){ index = _len + index; } if(index < 0 || index >= _len){ //TODO TROW ERR cout << "ERROR remove index out of range" << endl; return; } if(index == 0){ removeFirst(); } else if(index == _len-1) { removeLast(); } else { ListeItem *r = _getItem(index); ListeItem *b = r->_back; ListeItem *f = r->_front; b->_front = f; f->_back = b; delete r; _len--; } }
// ------------------------------------------------------------------------ // void xBlocksMap::AddLink( u32 pc, JccComparisonType cctype ) { recBlockItem& destItem( _getItem( pc ) ); const xJumpLink& newlink( destItem.DependentLinks.AddNew( xJumpLink( xGetPtr(), cctype ) ) ); newlink.SetTarget( m_xBlockLut[pc / 4] ); if( destItem.x86len != 0 ) { // Sanity Check: if block is already compiled, then the BlockPtr should *not* be dispatcher. jASSUME( m_xBlockLut[pc / 4] != DynFunc::Dispatcher ); } }
PlatChoisi* Liste::getObj(int index){ return (PlatChoisi *) _getItem(index)->getObj(); }