id
stringlengths
36
36
text
stringlengths
1
1.25M
9c10e72b-d09d-47b9-b7df-0488cfc799d3
public static void main(String[] args) throws IOException { if (args.length == 3) { String option = args[0]; File src = new File(args[1]), dest = new File(args[2]); if (option.equals("d")) { System.out.println("[Décompression...]"); Huffman.decompression(new FileInputStream(src), dest); return; } else if (option.equals("c")) { System.out.println("[Compression...]"); Huffman.compression(src, new FileOutputStream(dest)); return; } } System.out.println("Usage : [c|d] fichier.src fichier.dest"); }
d28265d4-c0d3-4970-923b-901d410f49d1
public Noeud(Element filsGauche, Element filsDroit) { super(); this.filsGauche = filsGauche; this.filsDroit = filsDroit; }
c83130da-1813-4351-8030-6cbf7bf7aec8
public void setFilsGauche(Element filsGauche) { this.filsGauche = filsGauche; }
7c74388a-3ad3-44f1-9018-52362b0d6e12
public void setFilsDroit(Element filsDroit) { this.filsDroit = filsDroit; }
75577ce2-55d6-41fa-8a5b-5ec3f422597b
public Element getFilsDroit() { return filsDroit; }
3418587f-3f45-48f0-93a6-13eeab0027c3
public Element getFilsGauche() { return filsGauche; }
5a7cdd17-9a66-4d2e-8188-6e632d3afc81
public ArbreHuffman() { feuilles = new Feuille[taille]; Feuille diese = new Feuille('#'); racine = diese; feuilles['#'] = diese; racine.setPoids(0); }
cf2232b1-8f3c-451c-8020-719cfb28357b
private void traitement(Element Q) { if (Q == null) { return; } else if (Q == feuilles ['#']){ racine.incrPoids(); }else if (estIncrementable(Q)) { incrementeChemin(Q); } else { Element m = premierIndice(Q); Element b = finBloc(m); incrementeChemin(Q, m); changerSousArbres(m, b); traitement(m.getPere()); } }
61bfa97f-261e-49a4-989d-85c0d9e679ef
public void modification(char symbole) { Element Q = feuilles[symbole]; Element diese = feuilles['#']; // si symbole n'est pas dans l'arbre if (Q == null) { Feuille f = new Feuille(symbole); Noeud nouveauNoeud = new Noeud(diese, f); // update de f f.setPere(nouveauNoeud); feuilles[symbole] = f; if (this.racine == diese) { diese.setPere(nouveauNoeud); this.racine = nouveauNoeud; } else { Noeud tmp = diese.getPere(); tmp.setFilsGauche(nouveauNoeud); nouveauNoeud.setPere(tmp); diese.setPere(nouveauNoeud); nouveauNoeud.setSuiv(diese.getSuiv()); Q = tmp; } diese.setSuiv(f); f.setSuiv(nouveauNoeud); } else { if (Q.getPere() == diese.getPere() && Q.getPere() == finBloc(Q)) { Q = Q.getPere(); } } traitement(Q); }
1198a127-0246-4649-a323-8d8bf25427bc
private Element finBloc(Element m) { for (; m != racine; m = m.getSuiv()) if (m.getPoids() < m.getSuiv().getPoids()) return m; return m; }
9e6978b1-a71b-42af-afa0-52c187c3a38d
private boolean estIncrementable(Element e) { for (; e != racine; e = e.getPere()) { if (e.getPoids() >= e.getSuiv().getPoids()) return false; } return true; }
bf80a200-ee92-460d-b908-ef4d94076395
private void incrementeChemin(Element e) { this.incrementeChemin(e, racine); }
3c0f5a40-813b-4320-b45b-9e011cc94172
private void incrementeChemin(Element e, Element m) { for (;; e = e.getPere()) { e.incrPoids(); if (e == m) return; } }
94bf5ec6-5b8e-4ffe-a11c-803cc51c9ed8
private Element premierIndice(Element e) { for (; e != racine; e = e.getPere()) if (e.getPoids() == e.getSuiv().getPoids()) return e; return e; }
ce137a8b-e343-4e19-92be-38af00344882
public static String parcoursInfixe(Element a) { if (a instanceof Feuille) { Feuille f = (Feuille) a; return "(" + f.getSymbole() + "," + f.getPoids() + ")"; } else { Noeud n = (Noeud) a; return parcoursInfixe(n.getFilsGauche()) + "[" + n.getPoids() + "]" + parcoursInfixe(n.getFilsDroit()); } }
fbef5189-cf70-4916-a755-7e224e69b002
private void changerSousArbres(Element premIndice, Element finBloc) { // Swap des deux arbres // On met à jour les fils des pères if (premIndice.estFilsGauche() && finBloc.estFilsGauche()) { premIndice.getPere().setFilsGauche(finBloc); finBloc.getPere().setFilsGauche(premIndice); } else if (premIndice.estFilsGauche() && !finBloc.estFilsGauche()) { premIndice.getPere().setFilsGauche(finBloc); finBloc.getPere().setFilsDroit(premIndice); } else if (!premIndice.estFilsGauche() && finBloc.estFilsGauche()) { premIndice.getPere().setFilsDroit(finBloc); finBloc.getPere().setFilsGauche(premIndice); } else { premIndice.getPere().setFilsDroit(finBloc); finBloc.getPere().setFilsDroit(premIndice); } // On inverse les pères Noeud pereFinBloc = finBloc.getPere(); finBloc.setPere(premIndice.getPere()); premIndice.setPere(pereFinBloc); // On met à jour les suivants updateNoeuds(); }
bfad6d77-e962-4331-bbab-25f9502c04b1
private void updateNoeuds() { List<Couple<Integer, Element>> liste = new ArrayList<Couple<Integer, Element>>(); parcoursLargeur(racine, 0, liste); Map<Integer, List<Element>> hmap = new HashMap<Integer, List<Element>>(); int max = 0; for (Couple<Integer, Element> c : liste) { if (hmap.get(c.niveau) == null) { hmap.put(c.niveau, new ArrayList<Element>()); } hmap.get(c.niveau).add(c.noeud); if (c.niveau > max) { max = c.niveau; } } Element n = null; for (int i = max; i >= 0; i--) { for (Element e : hmap.get(i)) { if (n != null) n.setSuiv(e); n = e; } } }
a5388e42-b2e0-4a0e-a187-683206322702
public Couple(T niveau, V noeud) { this.niveau = niveau; this.noeud = noeud; }
193179ab-4fa7-4425-9d9f-aecf71e3fb53
private void parcoursLargeur(Element a, int niveau, List<Couple<Integer, Element>> liste) { if (a instanceof Feuille) { liste.add(new Couple<Integer, Element>(niveau, a)); } else { Noeud n = (Noeud) a; liste.add(new Couple<Integer, Element>(niveau, a)); parcoursLargeur(n.getFilsGauche(), niveau + 1, liste); parcoursLargeur(n.getFilsDroit(), niveau + 1, liste); } }
b5ec8ee3-a4b6-4eb4-8ed9-51f0f28ca63c
public String toString() { StringBuilder str = new StringBuilder(); List<Couple<Integer, Element>> liste = new ArrayList<Couple<Integer, Element>>(); parcoursLargeur(racine, 0, liste); Map<Integer, List<Element>> hmap = new HashMap<Integer, List<Element>>(); int max = 0; for (Couple<Integer, Element> c : liste) { if (hmap.get(c.niveau) == null) { hmap.put(c.niveau, new ArrayList<Element>()); } hmap.get(c.niveau).add(c.noeud); if (c.niveau > max) { max = c.niveau; } } for (int i = 0; i <= max; i++) { for (Element e : hmap.get(i)) { if (e instanceof Feuille) { Feuille f = (Feuille) e; str.append("(" + f.getSymbole() + "," + f.getPoids() + ")\t"); } else { Noeud n = (Noeud) e; str.append("[" + n.getPoids() + "]\t"); } } str.append("\n"); } return str.toString(); }
f15e8e0c-7f7f-4f41-8f38-bf35cfc1aba3
public boolean estPresent(char symbole) { return feuilles[symbole] != null; }
e751adba-1f9c-4bf5-9588-9c5a16a1bdf6
public boolean estDiese() { return this.racine == feuilles['#']; }
152249b5-8714-436b-8037-1b37cb1db8c2
public Collection<Boolean> getCode(char symbole) { List<Boolean> chemin = new LinkedList<Boolean>(); for (Element f = feuilles[symbole]; f != racine; f = f.getPere()) chemin.add(!f.estFilsGauche()); Collections.reverse(chemin); return chemin; }
101f76c0-dc4d-41b3-8a51-7f59ac104012
public boolean estCheminComplet(Collection<Boolean> chemin) { Element e = racine; for (Boolean b : chemin) { if (e instanceof Feuille) return true; else if (b) e = ((Noeud) e).getFilsDroit(); else e = ((Noeud) e).getFilsGauche(); } return false; }
84a9fef8-ac31-49b8-9c35-87dff7b94b15
public char recupererFeuille(LinkedList<Boolean> chemin) { Element e = racine; while (true) { if (e instanceof Feuille) return ((Feuille) e).getSymbole(); else if (chemin.pop()) e = ((Noeud) e).getFilsDroit(); else e = ((Noeud) e).getFilsGauche(); } }
60907ee0-35b4-4143-9d67-693e1b9cfe86
public Element getRacine() { return racine; }
2ae6bf7d-5edd-4c9f-815d-e99489917fd2
public List<Parameter> findAll();
f5b7173c-a89c-4609-8dfb-ac875b02e87b
public List<Parameter> findAll(Sort arg0);
1d5fc4e2-2b2b-4a15-94a2-7ebf5f75edef
public List<Parameter> findAll(Iterable<String> arg0);
1338e57f-62be-43bb-9288-17945972c1b4
public Parameter getOne(String arg0);
4aceae43-e59f-442b-b86d-f9cc573c0832
public Page<Parameter> findAll(Pageable arg0);
0448ba81-da82-42c9-820a-909a887dcbbb
public long count();
cee672db-3a00-4605-9888-36fdb59988b4
public boolean exists(String arg0);
8052482f-f650-40cc-8190-c877babc2dfc
public Parameter findOne(String arg0);
2f11d2bc-fcb0-4b9a-af46-482e6f24eead
public <S extends Parameter> S save(S arg0);
99742fbc-9016-464c-b5d3-6c5c53a3219a
public void deleteAllInBatch() { // TODO Auto-generated method stub }
d8645bcd-9881-4b10-b3b7-4073c9921a3d
public void deleteInBatch(Iterable<Parameter> arg0) { // TODO Auto-generated method stub }
ad1ac0f9-f789-4e94-85ac-b47a94944110
public List<Parameter> findAll() { // TODO Auto-generated method stub return null; }
638590d0-b97d-44c3-8fde-4bc2d6299a91
public List<Parameter> findAll(Sort arg0) { // TODO Auto-generated method stub return null; }
9c2479b8-3eb4-4e23-80bd-7b8ff36d30e0
public List<Parameter> findAll(Iterable<String> arg0) { // TODO Auto-generated method stub return null; }
e332788c-9a29-4983-83df-64e30f1aec0d
public void flush() { // TODO Auto-generated method stub }
c667ce4f-7488-4ebe-9107-46040b4ef3c8
public Parameter getOne(String arg0) { // TODO Auto-generated method stub return null; }
092a7c86-419d-4fcd-aab9-e686c5580c2b
public <S extends Parameter> List<S> save(Iterable<S> arg0) { // TODO Auto-generated method stub return null; }
1168b85a-8c42-4cd9-9aea-a7f1e9610e64
public <S extends Parameter> S saveAndFlush(S arg0) { // TODO Auto-generated method stub return null; }
dafa5867-230b-45f1-aa56-3a787aca1a7d
public Page<Parameter> findAll(Pageable arg0) { // TODO Auto-generated method stub return null; }
7034e920-f380-4a10-bfb7-57c31f62367a
public long count() { // TODO Auto-generated method stub return 0; }
aee311d8-57e4-4bdf-9546-ee34875c11ab
public void delete(String arg0) { // TODO Auto-generated method stub }
07c2aa95-0fcb-4db1-87a7-db4ae986895b
public void delete(Parameter arg0) { // TODO Auto-generated method stub }
6a8795ac-bd8d-46e5-80b7-87b9830c751b
public void delete(Iterable<? extends Parameter> arg0) { // TODO Auto-generated method stub }
c19ae8fc-4ec7-403f-bc35-b06b539f270b
public void deleteAll() { // TODO Auto-generated method stub }
cb292475-3dcb-453e-be67-ec6d7b1e3088
public boolean exists(String arg0) { // TODO Auto-generated method stub return false; }
c759c007-475f-4526-a7ba-91a009d01cee
public Parameter findOne(String arg0) { // TODO Auto-generated method stub return null; }
eacc2583-f7ef-4e2f-bfee-59d6efac6294
public <S extends Parameter> S save(S arg0) { // TODO Auto-generated method stub return null; }
8cff29b6-79d7-4971-b5ae-8b7dc9705943
public String getCode() { return code; }
babcf870-c7be-4399-95dd-e12151669ae0
public void setCode(String code) { this.code = code; }
ec8ae241-f894-4b0f-9e13-8b25c7b93b01
public String getType() { return type; }
53414212-66c2-47c3-8153-b5bee2d82650
public void setType(String type) { this.type = type; }
08f6f485-227d-4867-818d-0b32eee610ef
public String getValue() { return value; }
564ed6ec-fec8-484e-bd18-734da08ac920
public void setValue(String value) { this.value = value; }
9ef411df-6b89-4d68-860e-b8559dc2cc94
public String getScope() { return scope; }
b4d75ce3-d8c2-40ba-b20e-a48344b27b78
public void setScope(String scope) { this.scope = scope; }
501ce79d-0c42-4f3e-9194-a94bf1a287d8
public String registerEvent(Event event);
1ab84b1f-81ed-47db-8071-709ecde43815
public boolean registerNewEventType(EventType eventType);
63d7976d-246c-40ce-93c7-78a9131869c6
public String getClientKey() { return clientKey; }
0cdf7344-29b4-4dc5-b5d0-2f39fd271bdd
public void setClientKey(String clientKey) { this.clientKey = clientKey; }
7f085f7a-6ca2-4c9d-8c24-99fb01c7913e
public String getEventType() { return eventType; }
633074c7-fb57-494b-9299-95e0bb1621b4
public void setEventType(String eventType) { this.eventType = eventType; }
ad1400a2-d652-4c90-82fa-f29837b69bf8
public Date getTimeStamp() { return timeStamp; }
1c568ffe-e4a4-467e-8b03-e11bce16f465
public void setTimeStamp(Date timeStamp) { this.timeStamp = timeStamp; }
70eb7df6-5406-4a88-9a2c-2c7ba94db809
public String getMiscInfo() { return miscInfo; }
774cf7f7-e701-4e3a-b062-293914dca382
public void setMiscInfo(String miscInfo) { this.miscInfo = miscInfo; }
de91b449-ed23-4d76-8d91-bf21654da862
public Priority getPriority() { return priority; }
3e7af736-164f-42e3-b309-b30011766588
public void setPriority(Priority priority) { this.priority = priority; }
2ba4cc43-10b5-4632-917b-9354fb3d0498
public String getEventType() { return eventType; }
e87946af-cfd2-44b2-9199-3d05d98280d0
public void setEventType(String eventType) { this.eventType = eventType; }
b278e428-d554-4484-9c29-8e2029f70cb0
public String getEventTypeDescription() { return eventTypeDescription; }
589fb875-4cb0-459c-94c2-153690c02563
public void setEventTypeDescription(String eventTypeDescrition) { this.eventTypeDescription = eventTypeDescrition; }
7342697f-9209-493a-8d12-82f65692436c
public static void main(String[] args) throws NamingException { System.out.println(new EvenRegistryClient().registerEvent()); }
2a953ba9-6034-4e14-8e57-d04293b6d14c
public String registerEvent() throws NamingException{ Context context = null; final Properties ejbProperties = new Properties(); ejbProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); context = new InitialContext(ejbProperties); String lookupName = "ejb:event-tador-ear/event-tador-ejb-impl/EventRegistryEJB!org.event.tador.ejb.api.EventRegistry"; eventRegistry = (EventRegistry)context.lookup(lookupName); return eventRegistry.registerEvent(new Event()); }
7035d0ea-77e0-497d-b9be-edb7229c1bde
public String registerEvent(Event event) { // TODO Auto-generated method stub return "eventRegistered"; }
fc17897d-33a3-4c2c-8ccf-13e2efe3dafe
public boolean registerNewEventType(EventType eventType) { // TODO Auto-generated method stub return false; }
96da4f6f-5246-464a-a93f-85c5d89da98f
public String getName() { return name; }
aa642701-4f95-4eb6-bafa-3017445535bc
public void setName(String name) { this.name = name; }
b113faf1-f0e5-4621-83a8-e4f5052c783f
public String getDisplayName() { return displayName; }
875e4b1a-cd3d-4d0e-a389-f99b4f149c2e
public void setDisplayName(String displayName) { this.displayName = displayName; }
ce430fbf-9bbf-4898-b501-201c0ddea2df
public String getLastName() { return lastName; }
61d20f14-5528-4305-a8a4-7326cdf81f53
public void setLastName(String lastName) { this.lastName = lastName; }
56a10e12-04b9-4a7c-aeb2-68e50d1c4a6b
public String getFirstName() { return firstName; }
a5e636f1-bbcd-45d8-a76f-0f8ebba45fe0
public void setFirstName(String firstName) { this.firstName = firstName; }
547ba3a6-e463-4c45-b4d4-53fa73f2c491
public String getMail() { return mail; }
de19c2df-fc3a-47c7-9022-f3c0bc0bc333
public void setMail(String mail) { this.mail = mail; }
acd71610-72e7-483a-aad2-7199709e43b8
public String getUserID() { return userID; }
74f8ac07-237e-4c86-89ab-50d471022935
public void setUserID(String userID) { this.userID = userID; }
4424ccf5-ad82-4650-8495-15cd1dd59f43
@Override public String toString() { return "Person{" + "name='" + name + '\'' + ", displayName='" + displayName + '\'' + ", lastName='" + lastName + '\'' + ", firstName='" + firstName + '\'' + ", mail='" + mail + '\'' + ", userID='" + userID + '\'' + '}'; }
9588e337-89ae-4410-a090-9fbeda19b91b
public void setLdapTemplate(LdapTemplate ldapTemplate) { this.ldapTemplate = ldapTemplate; }
7539c3e2-bf1b-42d2-b9c6-248d68fe3b25
@Override public List<Person> getAllPersons() { List<Person> contacts = new ArrayList<Person>(); try { List search = ldapTemplate.search("", "(objectClass=person)", new PersonAttributesMapper()); contacts.addAll(search); } catch (Exception e) { System.out.println("Exception while listing all users" + e); } return contacts; }
1310db3e-0a5c-4acc-b24c-95bb4ba22f8b
@Override public List findUserByCommonName(String commonName) { AndFilter andFilter = new AndFilter(); andFilter.and(new EqualsFilter("objectclass","person")); andFilter.and(new EqualsFilter("cn", commonName)); return ldapTemplate.search("", andFilter.encode(), new PersonAttributesMapper()); }
66e9fa99-7754-43d5-958d-7cfd9c71edc9
public List<Person> getAllPersons();
6daeeed0-ecff-4928-af15-a80bcaa41646
public List findUserByCommonName(String commonName);
d37f9294-9dec-43a4-b583-a2a7423a6431
@RequestMapping(value = "/ldap", method = RequestMethod.GET) public ModelAndView getLdapData() { List<Person> getAllPersons = personDAO.getAllPersons(); ModelAndView model = new ModelAndView("ldapAll"); model.addObject("listsLDAP", getAllPersons); return model; }