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 (46)
Showing
with 534 additions and 3 deletions
File added
<?xml version="1.0" encoding="UTF-8"?>
<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">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<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 ChainedList(Cursor cursor) {
this.cursor = cursor;
this.nbVal = 0;
}
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) {
if (nbVal == 0) {
Link new_link = new Link(value);
this.head = new_link;
this.head.last = new_link;
this.cursor.currentLink = new_link;
this.head.next = new_link;
}
else {
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;
}
this.nbVal += 1;
}
@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 Cursor() {
this.pos = 0;
}
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;
}
private void setList(ChainedList list) {
this.currentList = list;
this.currentLink = list.head;
}
}
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;
}
public Link(int value) {
this.value = value;
}
public void setNext(Link next) {
this.next = next;
}
public void setLast(Link last) {
this.last = last;
}
}
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();
arrayList = new ArrayList<Integer>();
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;
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();
linkedList = new LinkedList<Integer>();
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;
import java.util.Random;
import defaultpackage.Structure;
public class Table implements Structure
{
Integer[] tab;
public Table(int nbValue)
{
System.out.println("ajout d'une valeur");
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 defaultpackage;
import java.math.BigInteger;
import java.util.Random;
import PersonalStructure.ChainedList;
import PersonalStructure.Cursor;
import StandardStructure.ArrayListC;
import StandardStructure.LinkedListC;
import StandardStructure.Table;
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);
}
public static void GenerateTab(String type, int nbValue)
{
System.out.println("Je rentre : " + type);
if(type.equals("Tableau"))
{
Table tab = new Table(nbValue);
System.out.println("appeler");
}
if(type.equals("Array")) {
ArrayListC array = new ArrayListC(nbValue);
}
if(type.equals("Linked")) {
LinkedListC linked = new LinkedListC(nbValue);
}
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());
}
}
}
}
package defaultpackage;
public interface Structure
{
public void Add(int value);
public void Remove(int index) throws Exception;
public int Select(int index) throws Exception;
}
/defaultpackage/
/StandardStructure/
File added
File added
File added
File added
Manifest-Version: 1.0
Main-Class: defaultpackage.Main
...@@ -4,9 +4,29 @@ ...@@ -4,9 +4,29 @@
## Problème ## Problème
Description du Problème. **Langage utilisé**
Description de tous les paramètres exploratoires du problème Nous avons choisi d'utiliser le langage Java car il est plus adapté à notre organisation.
**Description du problème**
Analyse de performance de deux structures, faisant la même chose, mais fonctionnant différemment.
Deux paramètres au démarrage :
- Valeur que l'on veut trouver dans chaque tableau
- Nombre de valeurs dans chaque tableau :
- Chaque tableau génère x nombres aléatoires. De plus, nous indiquons le nombre que l'on veut trouver, qui doit être trouvé dans chaque tableau. Ainsi, le code nous renverra l’indice qui correspond à l’endroit où la valeur voulue se trouve dans le tableau et nous aurons un résultat correspondant à l'indice de la valeur trouvée dans chaque tableau
Contrainte : il faut de l’abstraction, et au moins un tableau ET une liste chaînée (Maillons)
**Description des paramètres exploratoires du problème**
- Analyser la différence de performance sur des opérations simples dans chaque structure (Inserer, Supprimer)
**Organisation du projet**
![](/UML_P4a.PNG)
## Dispositif expérimental ## Dispositif expérimental
...@@ -65,7 +85,11 @@ Expression précise et succincte d'une hypothèse. ...@@ -65,7 +85,11 @@ Expression précise et succincte d'une hypothèse.
### Protocole expérimental de vérification de l'hypothèse ### Protocole expérimental de vérification de l'hypothèse
Expression précise et succincte du protocole. - Temps d'exécution des deux programmes (et leur différence)
- Types de recherche de chaque programme (une standard et une recherche dichotomique)
- Comment le “Random” influe sur la performance des structures
- Comment améliorer la performance des deux structures
- Déterminer la classe de compléxité des structures
``` ```
Suite des commandes, ou script, à exécuter pour produire les données. Suite des commandes, ou script, à exécuter pour produire les données.
......
UML_P4a.PNG

52.9 KiB