A SortedMap yog a Daim Ntawv Qhia uas tswj hwm nws cov kev nkag mus rau hauv kev nce qib, txheeb raws li cov yuam sij 'natural order, lossis raws li tus Sib piv muab ntawm SortedMap tsim lub sijhawm.
Puas muaj daim ntawv qhia txheeb hauv Java?
SortedMap yog ib qho kev sib cuam tshuam hauv cov txheej txheem sau. Qhov kev sib txuas no txuas ntxiv rau Daim Ntawv Qhia interface thiab muab tag nrho cov kev txiav txim ntawm nws cov ntsiab lus (cov ntsiab lus tuaj yeem hla mus rau hauv kev txheeb xyuas cov yuam sij).
Daim ntawv qhia xaj yog dab tsi?
Ib daim ntawv qhia kev txiav txim (tseem hu ua daim ntawv qhia txuas hash hauv Java) yog a cov qauv ntaub ntawv uas tso cai rau rho tawm O(1) rau kev nkag mus thiab hloov pauv ib yam li daim ntawv qhia, tab sis cov khoom tswj lawv cov kev txiav txim. … Yog hais tias daim ntawv qhia hloov pauv thaum lub iteration yog nyob rau hauv-flight nws yuav ua rau tus cwj pwm tsis xav txog.
Puas daim ntawv qhia tsob ntoo yog txheeb daim ntawv qhia?
TreeMap hauv Java yog siv los siv Daim Ntawv Qhia interface thiab NavigableMap nrog rau Chav Kawm AbstractMap. Daim ntawv qhia yog txheeb raws li qhov kev txiav txim ntawm nws cov yawm sij, lossis los ntawm tus Sib piv muab rau lub sijhawm tsim daim ntawv qhia, nyob ntawm seb tus tsim siv twg siv.
Puas yog HashMap ib daim ntawv qhia kev txheeb xyuas?
HashMap tsis yog txhais tau tias khaws cov ntawv nkag hauv kev txiav txim, tab sis yog tias koj yuav tsum txheeb HashMap raws li cov yuam sij lossis qhov tseem ceeb, koj tuaj yeem ua qhov ntawd hauv Java. Kev txheeb HashMap ntawm cov yuam sij yog qhov yooj yim heev, txhua yam koj yuav tsum tau ua yog tsim TreeMap los ntawm kev luam cov ntawv nkag los ntawm HashMap. … Qhov no zoo ib yam li koj txheeb ArrayList hauv Java.