Hello everyone!
I'm currently making my own implementation of java.util.List, and it's going pretty well.
I've just run into a minor problem.
I'm currently doing the 'addAll(int index, Collection<?> c);' method.
But I can't seem to figure out how to make it start at the specified index.. this is the method so far:
@Override
public boolean addAll(int index, Collection<? extends E> c){
for(int i = index; i < c.size(); i++){
if(!add(c.iterator().next())){
return false;
}else{
continue;
}
}
return true;
}
And this is the output of an implementation looking like this:
Implementation.
NodeList<Integer> nodeList = new NodeList<Integer>(10);
List<Integer> list = new ArrayList<Integer>();
list.add(10);
list.add(20);
list.add(56);
list.add(45);
nodeList.addAll(2, list);
for(int i = 0; i < nodeList.size(); i++){
System.out.println(nodeList.get(i));
}
Output.
10
10
Please help me :).