Qhov kev sau twg tsis tso cai rau cov tswv cuab dua?
Qhov kev sau twg tsis tso cai rau cov tswv cuab dua?

Video: Qhov kev sau twg tsis tso cai rau cov tswv cuab dua?

Video: Qhov kev sau twg tsis tso cai rau cov tswv cuab dua?
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Hlis ntuj nqeg
Anonim

Duplicates: ArrayList tso cai rau duplicate qhov tseem ceeb thaum HashSet tsis pub duplicates qhov tseem ceeb. Ordering: ArrayList tswj qhov kev txiav txim ntawm cov khoom uas lawv tau muab tso rau thaum HashSet yog ib qho kev sau tsis tau xaj thiab tsis tuav ib qho kev txiav txim.

Tsis tas li lo lus nug yog, qhov kev sau twg tsis pub luam tawm?

HashSet

Qhov thib ob, dab tsi interface sawv cev rau cov khoom sau uas tsis tso cai rau cov khoom sib xws? Cov Sau Framework Piv txwv li, Daim Ntawv Teev Npe interface , qho sawv cev ib xaj sau , yog niam txiv interface ntawm tag nrho cov chav kawm sub thiab sub interfaces , xws li ArrayList, LinkedList, thiab lwm yam. Ib yam li ntawd, Lub Teeb interface txhais cov txheej ntawd tsis pub duplicate ntsiab.

Qhov thib ob, qhov kev sau dab tsi tsis tso cai rau cov tswv cuab sib npaug hauv Python?

Ib txheej tsis tuav luam tawm cov khoom. Cov cov ntsiab lus ntawm lub teeb yog immutable, uas yog , lawv hloov tsis tau, tab sis lub teeb nws tus kheej yog mutable, uas yog , nws ua tau hloov. Txij li cov khoom teeb tsa tsis yog ua indexed, sets tsis txhawb tej slicing los yog indexing ua hauj lwm.

Vim li cas cov duplicates tsis tso cai rau hauv teeb?

Lub ntsiab lus ntawm " teeb ua tsis yog tso cai luam tawm values" yog thaum koj ntxiv ib luam tawm rau a teeb , cov luam tawm yog ignored, thiab cov teeb tseem tsis hloov. Qhov no ua tsis yog ua rau compile lossis runtime yuam kev: duplicates nyob ntsiag to ignored. Teeb yog siv li ntawd kom tsis txhob duplication.

Pom zoo: