DESKTOP-IL3AS1R_20200907-陈鑫
问题:
@Override
public boolean containsAll(Collection<?> c) {//如果此 collection 包含指定 collection 中的所有元素,则返回 true
int temp=0;
if( c instanceof Box ) {
Box other = (Box) c ;
for (int i = 0; i < other.counter ; i++) {
E otherElements = (E) other.elements[i];
if(indexOf(otherElements)==-1) {
return false;
}
}
return true;
}
return false;
}
@Override
public boolean removeAll(Collection<?> c) {//移除此 collection 中那些也包含在指定 collection 中的所有元素
int oldCounter = counter ;
if( c instanceof Box ) {
Box other = (Box) c ;
for (int i = 0; i < other.counter ; i++) {
E otherElements = (E) other.elements[i];
remove(otherElements);
}
}
return oldCounter != counter ;
}
就暂时做出了这两个。
吐槽:
集合这部分的知识,感觉有点繁琐,有点绕
近期评论