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

Fin de création du Main

parent d7366e2e
Branches
No related merge requests found
import java.util.ArrayList;
import java.util.Random;
public class ArrayListWrapper<T> implements Structure {
ArrayList list = new ArrayList();
public class ArrayListWrapper implements Structure {
int size;
ArrayList<Integer> list;
Random r = new Random();
public ArrayListWrapper(int size) {
list = new ArrayList<Integer>(size);
}
@Override
public void insertQueue(int elem) {
list.add(list.size() - 1, elem);
......
import java.util.Random;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
arg0 = La taille de la structure
arg1 = Le choix de la structure
arg2 = Le nombre de répétion de l'opération choisi
arg3 = Le choix de l'opération à éxecuter
*/
if(args.length != 4) {
System.out.println("Usage: ./test <Structure size> <Structure type> <ammount of repetition> <Structure operation>");
System.exit(1);
}
int arg0 = Integer.parseInt(args[0]); //Size
int arg2 = Integer.parseInt(args[2]); //Ammount
Structure list = null; //List that will be tested
//Creation of the list
switch(args[1].toLowerCase()) {
case "array":
list = new Array(arg0);
break;
case "ourlinkedlist":
list = new OurLinkedList();
break;
case "arraylist":
list = new ArrayListWrapper(arg0);
break;
default:
System.out.println("arg1 must be either: array, ourlinkedlist or arraylist");
System.exit(1);
}
//Filling up the list with random values to prepare the tests
Random rnd = new Random();
for(int i = 0; i < arg0; i++) {
list.insertRandom(rnd.nextInt());
}
switch(args[3].toLowerCase()) {
case "get":
for(int i = 0; i<arg2; i++) {
list.get(rnd.nextInt(arg0));
}
break;
case "remove":
//TODO
break;
case "inserthead":
for(int i =0; i<arg2; i++) {
list.insertHead(rnd.nextInt());
}
break;
case "insertrandom":
for(int i =0; i<arg2; i++) {
list.insertRandom(rnd.nextInt());
}
break;
case "insertqueue":
for(int i =0; i<arg2; i++) {
list.insertQueue(rnd.nextInt());
}
break;
default:
System.out.println("arg3 must be either: get, remove, inserthead, insertrandom or insertqueue");
System.exit(1);
}
}
......
public interface Structure<T> {
public interface Structure {
//Insertions functions
public void insertQueue(int elem);
......
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