Skip to content
Snippets Groups Projects
Commit 73324e60 authored by Ewan Chauvin's avatar Ewan Chauvin
Browse files

Fixed ourlinkedlist issues

parent c7377c7b
Branches
No related merge requests found
......@@ -11,6 +11,11 @@ public class OurLinkedList implements Structure {
this.next = next;
this.previous = previous;
}
public Link(Integer value) {
this.value = value;
next = this;
previous = this;
}
}
public class Cursor {
......@@ -43,10 +48,12 @@ public class OurLinkedList implements Structure {
public void setPos(int pos) {
if(this.pos > pos) {
goBack();
} else {
} else if(this.pos < pos){
goFor();
}
setPos(pos);
if(this.pos != pos) {
setPos(pos);
}
}
}
......@@ -56,7 +63,7 @@ public class OurLinkedList implements Structure {
Random r = new Random();
public OurLinkedList() {
sentinel = new Link(0, sentinel, sentinel);
sentinel = new Link(0);
cursor = new Cursor(this, sentinel.previous);
nbVal = 0;
}
......@@ -76,7 +83,7 @@ public class OurLinkedList implements Structure {
}
private void insert(int pos, int val) {
if(pos < 0 || pos > nbVal || isEmpty()) {
if(pos < 0 || pos > nbVal) {
throw new IndexOutOfBoundsException("elem : mauvaise position du curseur");
}
int depart = cursor.pos;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment