commit fb0d2365b8cbbe8a87e348650b8379b123c6bbd7 Author: vaisse Date: Tue Sep 16 13:03:11 2025 +0200 save diff --git a/src/Node.class b/src/Node.class new file mode 100644 index 0000000..2634550 Binary files /dev/null and b/src/Node.class differ diff --git a/src/Node.java b/src/Node.java new file mode 100644 index 0000000..95fb5cf --- /dev/null +++ b/src/Node.java @@ -0,0 +1,152 @@ +//IMPORTS +import java.util.LinkedList; +import java.util.*; +import java.util.Arrays; + +public class Node{ + //ATTRIBUTS + /*----------------------------------------------------------------------------------*/ + private String value; + private LinkedList successors = new LinkedList(); + private int successors_len = 0; + private int depth = 0; + + //ASSOCIATIONS DIRECTES + private LinkedList directedfrom = new LinkedList(); + private LinkedList directedto = new LinkedList(); + + //PARAMETRES CUSTOMISES + /*le dictionnaire de paramètres customisés n'est pas ordonné. A prenre en compte + lors de la conception ou de la modification de fonctionnalités.*/ + private Map custom_parameters = new HashMap(); + private Set> cstprms_entry = custom_parameters.entrySet(); + private Set keys; + /*----------------------------------------------------------------------------------*/ + //FIN ATTRIBUTS + + + //METHODES + /*----------------------------------------------------------------------------------*/ + /*methodes params customs*/ + private void updateKeysForCustParams(){ + this.keys = this.custom_parameters.keySet(); + } + + public boolean newCustomParameter(String name, String value){ + if(this.custom_parameters.containsKey(name)){ + System.out.println("FAILED:UNIQUE NAME CONSTRAINT VIOLATED"); + return false; + } + this.custom_parameters.put(name, value); + this.updateKeysForCustParams(); + return true; + } + + public boolean editCustomParameter(String name, String value){ + if(this.custom_parameters.containsKey(name)){ + this.custom_parameters.remove(name); + this.custom_parameters.put(name, value); + this.updateKeysForCustParams(); + return true; + } else { + System.out.println("FAILED:PARAMETER NOT REGISTERED IN MAP"); + return false; + } + } + + public boolean removeCustomParameter(String name, String value){ + if(!this.custom_parameters.containsKey(name)){ + System.out.println("FAILED:PARAMETER NOT REGISTERED IN MAP"); + return false; + } + this.custom_parameters.remove(name); + this.updateKeysForCustParams(); + return true; + } + + public String getCustomParam(String name){ + if(!this.custom_parameters.containsKey(name)){ + System.out.println("FAILED:PARAMETER NOT REGISTERED IN MAP"); + return ""; + } + return this.custom_parameters.get(name); + } + + /*----------------------------------------------------------------------------------*/ + /*methodes associations dirigées*/ + + public void addDirectedAssociation(Node n){ + this.directedto.add(n); + } + + public void addDirectedAssociationParent(Node n){ + this.directedfrom.add(n); + } + + /*----------------------------------------------------------------------------------*/ + /*methodes generales*/ + public String getVal(){ + return this.value; + } + + public int getDepth(){ + return this.depth; + } + + public void updateDepth(int val){ + this.depth = val; + } + + public Node getSuccessorAt(int index){ + return this.successors.get(index); + } + + public void addSuccessor(Node n){ + n.updateDepth(this.depth+1); + this.successors.add(n); + this.successors_len++; + } + + public void addSuccessors(Node[] ns){ + for(int i=0; i"); + return; + } + + //fin tests + + //variables + LinkedList pool = new LinkedList(); + Random randgen = new Random(); + int added_links = 0; + int r1, r2; + + //fin variables + + + //prog + for(int i=0; i