You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
可以这样,可不用考虑索引顺序影响:
Set set = oc(sensitivity, datas);
double[] doubles = new double[datas.length - set.size()];
int index = 0;
for (int i = 0; i < datas.length; i++) {
if (!set.contains(i)) {
doubles[index++] = datas[i];
}
}
return doubles;
fusionToList方法存在bug,Set是无序集合,里面异常数据索引有可能不是按照正常顺序存放的。所以在for循环中不会与datas索引一样按顺序取数据。
@OverRide
public double[] fusionToList(int sensitivity, double[] datas) {
Set set = oc(sensitivity, datas);
double[] doubles = new double[datas.length - set.size()];
Iterator iterator = set.iterator();
Integer next = iterator.hasNext() ? iterator.next() : null;
int index = 0;
for (int i = 0; i < datas.length; i++) {
if (next != null && next.equals(i)) {
next = iterator.hasNext() ? iterator.next() : null;
continue;
}
doubles[index++] = datas[i];
}
return doubles;
}
The text was updated successfully, but these errors were encountered: