So a while ago I asked about DLL's and making them. Well I should have waited till today to ask my question because the teacher managed to do an implentation using a dllnode class he wrote and the remove method. the code is bellow. Well its after class and theres an error and the instructor can't help and the assignment is due tomorrow.
"Wait how is he a plagerizer?" you'll see, look at linked list for this code >_<
//remove at said index
@Override
public E remove(int index) throws IndexOutOfBoundsException
{
return remove(indexEntry(index));
}
// Find the next index value
private DllNode<E> indexEntry(int index)
{
if (index <0 || index > size)
{
throw new IndexOutOfBoundsException();
}
DllNode<E> element = header;
if (index < (size >> 1))
{
for (int i = 0; i <= index; i++)
{
element = element.getNext();
}
}
else
{
for (int i= 0; i > index; i--)
{
element = element.getPrev();
}
}
return element;
}
the error is on the remove method call. saying that i need to convert the indexEntry to int or place DllNode<E> with in the parameter for remove....
The teachers code is the same, his works, this code, upon further investigation is IDENTICLE to that of the linkedlist code for the java source.
any help as to why I am throwing this error?