0

我想从数组中删除一个对象。问题是我不知道索引,所以我尝试了 remove 方法。

该方法定义如下:

void ofxDTangibleManager::updateList(vector<ofxDTangible> &oldList, vector<ofxDTangible> &newList) {

这是出错的部分:

for(int i = 0; i < oldList.size(); i++) {

    if(newList.size() == 0) {
        break;
    }

    ofxDTangible &t = oldList[i];

    ofxDTangible &closest = getClosestTangible(t, newList, false);

    float d = distSquared(t, closest);

    if(d < maxMoveDistSquared) {
        refound[i] = true;
        // copy values of new one over
        // todo
        // set as target so we can interpoplate if required

        // remove it so we make sure we don't assign it to multiple tangibles
        remove(newList.begin(), newList.end(), closest);
    }
}

这是错误: 错误

我怎样才能解决这个问题?

4

0 回答 0