TreeMap & TreeSet
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
TreeMap dhe TreeSet i mbajnë elementet gjithmonë të renditur — sipas alfabetit ose numrave. Janë pak më të ngadalta se HashMap/HashSet, por kur kalon nëpër to, dalin me radhë.
EnglishEN
TreeMap and TreeSet keep their items always sorted — alphabetically or numerically. They're slightly slower than HashMap/HashSet, but when you loop through them, items come out in order.
Si ta mendosh
Si regjistri i klasës: emrat janë gjithmonë sipas alfabetit, sido që të jenë shtuar.
Lexoje në anglisht
Like the class register: names are always alphabetical, whatever order they were added.
Shembull kodijava
TreeMap<String, Integer> notat = new TreeMap<>();
notat.put("Ilir", 4); notat.put("Arta", 5);
System.out.println(notat); // {Arta=5, Ilir=4}