HashMap yog dab tsi hauv Python?
HashMap yog dab tsi hauv Python?

Video: HashMap yog dab tsi hauv Python?

Video: HashMap yog dab tsi hauv Python?
Video: Python! Switching Dictionary Keys and Values 2024, Hlis ntuj nqeg
Anonim

Hauv computer science, Hash table los yog a Hashmap yog ib hom ntaub ntawv qauv uas qhia cov yuam sij rau nws tus nqi khub (siv cov ntaub ntawv paub daws teeb array hom). Hash tables los yog muaj maps hauv Python yog siv los ntawm cov ntaub ntawv txhais lus hauv built-in. Cov yuam sij ntawm phau ntawv txhais lus hauv Python yog tsim los ntawm hashing muaj nuj nqi.

Ntawm no, Python phau ntawv txhais lus yog HashMap?

Nyeem mus saib yuav ua li cas cov Python txheem tsev qiv ntawv yuav pab tau koj. Hauv Python , phau ntawv txhais lus (lossis "dicts", luv luv) yog cov qauv ntaub ntawv hauv nruab nrab: Cov ntawv sau cia cov khoom siv tsis raug, txhua tus txheeb xyuas los ntawm qhov tshwj xeeb. phau ntawv txhais lus tus yuam sij. Phau ntawv txhais lus feem ntau kuj hu ua maps, hashmaps , lookup tables, los yog associative arrays.

Puas yog Python teeb lub rooj hash? Hash rooj yog siv los ua daim ntawv qhia thiab teeb cov ntaub ntawv tsim nyob rau hauv ntau hom lus programming, xws li C ++, Java, thiab Python . Python siv rooj rooj rau phau ntawv txhais lus thiab teeb . A rooj rooj yog ib qho kev sau tsis raug ntawm cov khoom tseem ceeb-tus nqi, qhov twg txhua tus yuam sij yog qhov tshwj xeeb.

Xav txog qhov no, HashMap siv rau dab tsi?

HashMap yog ib daim ntawv qhia raws li chav kawm sau uas yog siv rau khaws Key & nqi khub, nws yog denoted li HashMap los yog HashMap . Cov chav kawm no ua rau tsis muaj kev lees paub raws li qhov kev txiav txim ntawm daim ntawv qhia. Nws zoo ib yam li Hashtable chav kawm tshwj tsis yog tias nws yog unsynchronized thiab tso cai nulls (null values thiab null key).

Qhov txawv ntawm HashMap thiab Hashtable yog dab tsi?

Muaj ob peb Qhov sib txawv ntawm HashMap thiab Hashtable hauv Java: Hashable yog synchronized, whereas HashMap tsis yog. Qhov no ua rau HashMap zoo dua rau cov ntawv thov uas tsis yog xov, raws li cov khoom tsis sib xws feem ntau ua tau zoo dua li cov khoom sib txuas. Hashable tsis pub cov yuam sij null lossis cov nqi.

Pom zoo: