Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (37)
Showing
with 422 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-13.0.2">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="Common"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>P4a</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=15
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=15
package PersonalStructure;
import defaultpackage.Structure;
public class ChainedList implements Structure {
protected Link head;
protected Cursor cursor;
protected int nbVal;
public ChainedList(Link head, Cursor cursor) {
this.head = head;
this.cursor = cursor;
this.nbVal = 1;
}
public void setNextLink(Link currentLink)
{
Link last_next = this.cursor.currentLink.next;
this.cursor.currentLink.next = currentLink;
nbVal+=1;
}
public void setPreviousLink(Link currentLink)
{
Link last_next = this.cursor.currentLink.next;
this.cursor.currentLink.next = currentLink;
nbVal+=1;
}
public Link getLink()
{
return this.cursor.currentLink;
}
public Link getNextLink()
{
return this.cursor.currentLink.next;
}
public Link getPreviousLink(Link currentLink)
{
return this.cursor.currentLink.next;
}
public void replaceCursor(int position)
{
this.cursor.position(position);
}
public boolean isEmpty() {
boolean res = false;
if(this.nbVal != 0)
res = true;
return res;
}
@Override
public void Add(int value) {
this.replaceCursor(this.nbVal);
Link last_before_added = this.cursor.currentLink.last;
Link next_after_added = this.head;
Link new_link = new Link(value, next_after_added, last_before_added);
last_before_added.next = new_link;
this.head.last = new_link;
this.cursor.currentLink = new_link;
}
@Override
public void Remove(int index) throws Exception {
if ((index < 0) && isEmpty())
throw new IndexOutOfBoundsException("Wrong position");
this.replaceCursor(index);
Link last_of_remove = this.cursor.currentLink.last;
Link next_of_remove = this.cursor.currentLink.next;
last_of_remove.next = next_of_remove;
next_of_remove.last = last_of_remove;
this.cursor.currentLink = next_of_remove;
}
@Override
public int Select(int index) throws Exception {
if ((index < 0) && isEmpty())
throw new IndexOutOfBoundsException("Wrong position");
this.replaceCursor(index);
return this.cursor.currentLink.value;
}
}
package PersonalStructure;
public class Cursor {
protected Link currentLink;
protected ChainedList currentList;
protected int pos;
public Cursor(ChainedList currentList, Link currentLink, int pos) {
this.currentLink = currentLink;
this.currentList = currentList;
this.pos = pos;
}
public void position(int pos)
{
// si on est arrivé à la bonne position, on garde le maillon actuel
if (pos == this.pos)
{ }
// si nous sommes avant la position voulue, on avance
else if (pos > this.pos)
{
while(pos != this.pos)
{
goForward();
}
}
// si nous sommes après la position voulue, on recule
else if (pos < this.pos)
{
while(pos != this.pos)
{
goBack();
}
}
}
private void goForward() {
// si on n'est pas encore arrivé à la fin de la liste, on avance
if(this.pos <= this.currentList.nbVal)
{
this.pos += 1;
this.currentLink = this.currentLink.next;
}
// sinon on retourne au début de la liste
else {
this.pos = 0;
this.currentLink = this.currentList.head;
}
}
private void goBack() {
// si on n'est pas encore arrivé au début de la liste, on recule
if(this.pos >= 0)
{
this.pos -= 1;
}
// sinon on va à la fin de la liste
else {
this.pos = this.currentList.nbVal;
}
// on recule toujours
this.currentLink = this.currentLink.last;
}
}
package PersonalStructure;
public class Link {
protected int value;
protected Link next;
protected Link last;
public Link(int value, Link next, Link last) {
this.value = value;
this.next = next;
this.last = next;
}
}
package StandardStructure;
import defaultpackage.Structure;
import java.util.ArrayList;
import java.util.Random;;
public class ArrayListC implements Structure
{
protected ArrayList<Integer> arrayList;
public ArrayListC(int nbValue)
{
Random rnd = new Random();
for(int i = 0; i <= nbValue; i++)
{
Add(rnd.nextInt());
}
}
@Override
public void Add(int value)
{
arrayList.add(value);
}
@Override
public void Remove(int index) throws Exception
{
try
{
arrayList.remove(index);
}
catch(IndexOutOfBoundsException e)
{
throw new Exception("L'index dfini ne se situe pas dans les bornes du tableau");
}
}
@Override
public int Select(int index) throws Exception
{
try
{
return arrayList.get(index);
}
catch(IndexOutOfBoundsException e)
{
throw new Exception("L'index dfini ne se situe pas dans les bornes du tableau");
}
}
}
package StandardStructure;
public class ArrayListWrapper {
}
package StandardStructure;
import java.util.LinkedList;
import java.util.Random;
import defaultpackage.Structure;
public class LinkedListC implements Structure
{
LinkedList<Integer> linkedList;
public LinkedListC(int nbValue)
{
Random rnd = new Random();
for(int i = 0; i <= nbValue; i++) {
Add(rnd.nextInt());
}
}
@Override
public void Add(int value) {
// TODO Auto-generated method stub
linkedList.add(value);
}
@Override
public void Remove(int index) throws Exception {
// TODO Auto-generated method stub
try
{
linkedList.remove(index);
}
catch(IndexOutOfBoundsException e)
{
throw new Exception("L'index dfini ne se situe pas dans les bornes du tableau");
}
}
@Override
public int Select(int index) throws Exception
{
// TODO Auto-generated method stub
try
{
return linkedList.get(index);
}
catch(IndexOutOfBoundsException e)
{
throw new Exception("L'index dfini ne se situe pas dans les bornes du tableau");
}
}
}
package StandardStructure;
public class LinkedListWrapper {
}
package StandardStructure;
import java.util.Random;
import defaultpackage.Structure;
public class Table implements Structure
{
Integer[] tab;
public Table(int nbValue)
{
Random rnd = new Random();
tab = new Integer[nbValue];
for(int i = 0; i <= nbValue; i++)
{
tab[i] = rnd.nextInt();
}
}
@Override
public void Add(int value) {
// TODO Auto-generated method stub
Integer[] temp = new Integer[tab.length + 1];
for(int i = 0; i < tab.length; i++) {
temp[i] = tab[i];
}
temp[temp.length] = value;
tab = temp;
}
@Override
public void Remove(int index) throws Exception
{
// TODO Auto-generated method stub
try
{
tab[index] = null;
}
catch(IndexOutOfBoundsException e)
{
throw new Exception("L'index dfini ne se situe pas dans les bornes du tableau");
}
}
@Override
public int Select(int index) throws Exception
{
// TODO Auto-generated method stub
try
{
return tab[index];
}
catch(IndexOutOfBoundsException e)
{
throw new Exception("L'index dfini ne se situe pas dans les bornes du tableau");
}
}
}
package StandardStructure;
public class TableWrapper {
}
package defaultpackage;
public interface Structure
{
boolean wantTab = false;
boolean wantArray = false;
boolean wantLinked = false;
boolean wantMaillon = false;
public static void GenerateTab(boolean wantTab, boolean wantArray, boolean wantLinked, boolean wantMaillon)
{
}
public void Add(int value);
public void Remove(int index) throws Exception;
public int Select(int index) throws Exception;
}
File added
File added
File added
File added
File added
File added
File added