Exemplo n.º 1
0
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++;
	}
}
Exemplo n.º 2
0
    int tcpCommandQueue::pushFirst(QByteArray cmd, tcpDriverDataTypes::dataType type)
    {
        tcpCommand* tmpCmd = new tcpCommand(cmd,type);
        pushFirst(tmpCmd);

        return 0;
    }
Exemplo n.º 3
0
void Liste::pushLast(void *obj){
	if(_first == NULL){
		pushFirst(obj);
	} else {		
		ListeItem *newL = new ListeItem(_last, NULL, obj);
		_last->_front = newL;
		_last = newL;
		
		_len++;
	}
}