Skip to content
Snippets Groups Projects
Commit 9f7e24b3 authored by Heyd's avatar Heyd
Browse files

Correction du fonctionnement de ChainedList

parent 59150eb9
Branches
No related merge requests found
......@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="Common"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-15.0.2">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
<attributes>
<attribute name="module" value="true"/>
</attributes>
......
......@@ -14,6 +14,7 @@ public class ChainedList implements Structure {
public ChainedList(Cursor cursor) {
this.cursor = cursor;
this.cursor.setList(this);
this.nbVal = 0;
}
......@@ -38,6 +39,11 @@ public class ChainedList implements Structure {
return this.cursor.currentLink;
}
public Cursor getCursor()
{
return this.cursor;
}
public Link getNextLink()
{
return this.cursor.currentLink.next;
......@@ -72,7 +78,7 @@ public class ChainedList implements Structure {
this.head.next = new_link;
}
else {
System.out.println("val = " + value);
this.replaceCursor(this.nbVal);
Link last_before_added = this.cursor.currentLink.last;
......@@ -86,7 +92,7 @@ public class ChainedList implements Structure {
this.cursor.currentLink = new_link;
}
this.nbVal += 1;
System.out.println("nbVal = " + this.nbVal);
}
@Override
......
......@@ -66,7 +66,7 @@ public class Cursor {
this.currentLink = this.currentLink.last;
}
private void setList(ChainedList list) {
public void setList(ChainedList list) {
this.currentList = list;
this.currentLink = list.head;
}
......
......@@ -15,8 +15,8 @@ public class Main {
public static void main(String[] args) {
System.out.println("Je suis ici");
// TODO Auto-generated method stub
// GenerateTab(args[0], Integer.parseInt(args[1]));
GenerateTab("Maillon", 100);
GenerateTab(args[0], Integer.parseInt(args[1]));
//GenerateTab("Maillon", 1000000);
}
public static void GenerateTab(String type, int nbValue)
......@@ -42,9 +42,7 @@ public class Main {
if(type.equals("Maillon")) {
Cursor cursor = new Cursor();
ChainedList maillons = new ChainedList(cursor);
Random rnd = new Random();
for(int i = 0; i < nbValue; i++) {
maillons.Add(rnd.nextInt());
}
......
/defaultpackage/
/StandardStructure/
No preview for this file type
No preview for this file type
No preview for this file type
File added
File added
No preview for this file type
File added
File added
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