Skip to content
Snippets Groups Projects
Commit 414241a7 authored by KLEIN ISABELLE's avatar KLEIN ISABELLE
Browse files

Upload New File

parent bd0cfa19
Branches
No related merge requests found
package p4a;
import java.util.LinkedList;
public class SLinkedList implements Structure{
/**
* @attributs
*/
private LinkedList<Double> ll;
private int ordre=1000;
/**
* @constructeur
*/
public SLinkedList(int ordre) {
ll = new LinkedList<Double>();
this.ordre=ordre;
}
/**
* @méthodes
*/
public void ajoutEnTete(int nbElements){
for (int i = 0;i<nbElements;i++){
ll.add(0,Math.random()*ordre);
}
}
public void ajoutEnQueue(int nbElements){
for (int i = 0;i<nbElements;i++){
ll.add(Math.random()*ordre);
}
}
public void supprEnTete(int nbElements){
for (int i = 0;i<nbElements;i++){
ll.remove(0);
}
}
public void supprEnQueue(int nbElements){
for (int i = 0;i<nbElements;i++){
ll.remove(ll.size()-1);
}
}
public int rechercher(Object e){
int trouve =-1;
for (int i=0; i < ll.size(); i++){
if(ll.get(i)==e){
trouve=i;
}
}
return trouve;
}
public void afficher(){
System.out.println("\n Structure LinkedList : ");
for (int i=0; i < ll.size(); i++){
System.out.println(ll.get(i)+", ");
}
}
}
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