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
Showing
with 257 additions and 0 deletions
File added
package p4a;
public class MainArrayListStdAddDebut {
public static void main(String[] args) {
ArrayListStd<Integer> arrayListStd = new ArrayListStd<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
arrayListStd.ajout(0, 0);
}
}
}
package p4a;
public class MainArrayListStdAddFin {
public static void main(String[] args) {
ArrayListStd<Integer> arrayListStd = new ArrayListStd<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
arrayListStd.ajout(0, i);
}
}
}
package p4a;
import java.util.Random;
public class MainArrayListStdGet {
public static void main(String[] args) {
Random rnd = new Random();
ArrayListStd<Integer> arrayListStd = new ArrayListStd<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
arrayListStd.ajout(0, i);
}
for (int i = 0; i < nbOperation; i++) {
arrayListStd.acces(rnd.nextInt(nbOperation));
}
}
}
File added
package p4a;
public class MainLinkedListPersoAddDebut {
public static void main(String[] args) {
LinkedListPerso<Integer> linkedListStd = new LinkedListPerso<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
linkedListStd.ajout(0, 0);
}
}
}
package p4a;
public class MainLinkedListPersoAddFin {
public static void main(String[] args) {
LinkedListPerso<Integer> linkedListStd = new LinkedListPerso<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
linkedListStd.ajout(0, i);
}
}
}
File added
package p4a;
public class MainLinkedListStdAddDebut {
public static void main(String[] args) {
LinkedListStd<Integer> linkedListStd = new LinkedListStd<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
linkedListStd.ajout(0, 0);
}
}
}
package p4a;
public class MainLinkedListStdAddFin {
public static void main(String[] args) {
LinkedListStd<Integer> linkedListStd = new LinkedListStd<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
linkedListStd.ajout(0, i);
}
}
}
package p4a;
import java.util.Random;
public class MainLinkedListStdGet {
public static void main(String[] args) {
Random rnd = new Random();
LinkedListStd<Integer> linkedListStd = new LinkedListStd<Integer>();
int nbOperation = Integer.parseInt(args[0]);
for (int i = 0; i < nbOperation; i++) {
linkedListStd.ajout(0, i);
}
for (int i = 0; i < nbOperation; i++) {
linkedListStd.acces(rnd.nextInt(nbOperation));
}
}
}
package p4a;
public class MainTableauPersoAdd {
public static void main(String[] args) {
int nbOperation = Integer.parseInt(args[0]);
TableauPerso tabStd = new TableauPerso(nbOperation);
for (int i = 0; i < nbOperation; i++) {
tabStd.ajout(0, i);
}
}
}
package p4a;
public class MainTableauStdAdd {
public static void main(String[] args) {
int nbOperation = Integer.parseInt(args[0]);
TableauStd tabStd = new TableauStd(nbOperation);
for (int i = 0; i < nbOperation; i++) {
tabStd.ajout(0, i);
}
}
}
package p4a;
import java.util.Random;
public class MainTableauStdGet {
public static void main(String[] args) {
Random rnd = new Random();
int nbOperation = Integer.parseInt(args[0]);
TableauStd tabStd = new TableauStd(nbOperation);
for (int i = 0; i < nbOperation; i++) {
tabStd.ajout(0, i);
}
for (int i = 0; i < nbOperation; i++) {
tabStd.acces(rnd.nextInt(nbOperation));
}
}
}
File added
package p4a;
public interface Structure {
public void ajout(Object element, int position);
public void suppression(int position);
public Object acces(int position);
}
File added
package p4a;
public class TableauPerso implements Structure{
private Object[] tableau;
private int nbElements;
public TableauPerso(int taille) {
if (taille < 0) {
throw new IllegalArgumentException("TableauPerso : taille negative " + taille);
}
this.tableau = new Object[taille];
nbElements = 0;
}
@Override
public void ajout(Object element, int position) {
if (position < 0 || position > nbElements) {
throw new IndexOutOfBoundsException("ajout : mauvais index " + position);
}
if (nbElements >= tableau.length) {
throw new IllegalStateException("ajout : tableau plein");
}
for (int i = nbElements; i > position; i--) {
tableau[i] = tableau[i - 1];
}
tableau[position] = element;
nbElements++;
}
@Override
public void suppression(int position) {
if (position < 0 || position >= nbElements) {
throw new IndexOutOfBoundsException("suppression : position incorrecte " + position);
}
for (int i = position + 1; i < nbElements; i++) {
tableau[i - 1] = tableau[i];
}
nbElements--;
}
@Override
public Object acces(int position) {
if (position > tableau.length || position < 0) {
throw new IllegalArgumentException("acces : position incorecte");
}
return tableau[position];
}
}
File added
package p4a;
public class TableauStd implements Structure {
private Object[] tableau;
public TableauStd(int taille) {
if (taille < 0) {
throw new IllegalArgumentException("TableauStd : taille negative " + taille);
}
this.tableau = new Object[taille];
}
@Override
public void ajout(Object element, int position) {
if (position > tableau.length) {
throw new UnsupportedOperationException("ajout : operation non supportee (taille depassee)");
}
else tableau[position] = element;
}
@Override
public void suppression(int position) {
throw new UnsupportedOperationException("suppression : operation non supportee");
}
@Override
public Object acces(int position) {
if (position > tableau.length || position < 0) {
throw new IllegalArgumentException("acces : position incorecte");
}
return tableau[position];
}
}