Java TreeMap yog dab tsi?
Java TreeMap yog dab tsi?

Video: Java TreeMap yog dab tsi?

Video: Java TreeMap yog dab tsi?
Video: HashMap in Java | Hashing | Java Placement Course | Data Structures & Algorithms 2024, Kaum ib hlis
Anonim

Java TreeMap chav kawm yog ib tsob ntoo liab-dub raws li kev siv. Nws muab cov txiaj ntsig zoo ntawm kev khaws cov khoom tseem ceeb-tus nqi hauv kev txheeb xyuas. Cov ntsiab lus tseem ceeb txog Java TreeMap chav kawm yog: Java TreeMap muaj nuj nqis raws li tus yuam sij. Nws siv NavigableMap interface thiab txuas ntxiv chav kawm AbstractMap.

Hais txog qhov no, TreeMap yog dab tsi hauv Java nrog piv txwv?

TreeMap hauv Java nrog Piv txwv . Los ntawm Chaitanya Singh | Filed under: Java Kev sau. TreeMap yog tsob ntoo Liab-Dub raws li kev siv NavigableMap. Nws raug txheeb raws li qhov kev txiav txim ntawm nws cov yuam sij. TreeMap chav kawm siv Map interface zoo ib yam li HashMap chav kawm.

Ib tug kuj tseem nug, TreeMap ua haujlwm li cas? TreeMap hauv Java. Cov TreeMap yog siv los siv Map interface thiab NavigableMap nrog rau Chav Kawm Abstract. Tsis tas li ntawd, tag nrho nws cov khoom khaws cia hauv lub TreeMap raug txheeb los ntawm qhov tseem ceeb. TreeMap ua sorting nyob rau hauv natural order ntawm nws tus yuam sij, nws kuj tso cai rau koj siv Comparator rau kev cai sorting siv.

Ib sab ntawm no, vim li cas peb thiaj siv TreeMap hauv Java?

Cov TreeMap hauv Java yog siv los siv Daim Ntawv Qhia interface thiab NavigableMap nrog rau Chav Kawm Abstract. Daim ntawv qhia yog txheeb raws li qhov kev txiav txim ntawm nws cov yuam sij, lossis los ntawm tus Sib piv muab rau lub sijhawm tsim daim ntawv qhia, nyob ntawm seb tus tsim qauv twg yog siv.

Qhov txawv ntawm TreeMap thiab HashMap hauv Java yog dab tsi?

Major Qhov sib txawv ntawm HashMap thiab TreeMap Daim duab yog ib qho piv txwv ntawm SortedMap thiab yog siv los ntawm yog siv los ntawm tsob ntoo Liab-Dub, uas txhais tau hais tias qhov kev txiav txim ntawm cov yuam sij raug txheeb xyuas. HashMap ntawm qhov tod tes, ua rau tsis muaj qhov lav. Nws yog siv los ntawm Hash Table.

Pom zoo: