Muaj pes tsawg lub vectors tuav tau?
Muaj pes tsawg lub vectors tuav tau?

Video: Muaj pes tsawg lub vectors tuav tau?

Video: Muaj pes tsawg lub vectors tuav tau?
Video: E ëma i tregoi të vërtetën pas 40 vitesh, vajza kërkon prindërit biologjikë: Nuk i gjykoj 2024, Hlis ntuj nqeg
Anonim

Qhov no txhais tau tias cov vector tau pib 15 cov ntsiab lus rau lawv tus nqi pib.

Ib yam li ntawd, tib neeg nug, lub peev xwm ntawm vector yog dab tsi?

Qhov loj ntawm a vector yog tus naj npawb ntawm cov ntsiab lus uas nws muaj, uas yog ncaj qha tswj los ntawm pes tsawg lub ntsiab koj muab tso rau hauv vector . Muaj peev xwm yog tus nqi ntawm qhov chaw uas tus vector tam sim no siv. Cov muaj peev xwm ntawm vector yog qhov loj ntawm qhov array. Qhov no yeej ib txwm sib npaug los yog loj dua qhov loj.

Tom qab ntawd, lo lus nug yog, ua li cas koj pom qhov ntev ntawm vector? qhov loj () - Rov qab cov naj npawb ntawm cov ntsiab lus hauv vector . max_size() – Rov qab cov ntsiab lus ntau tshaj plaws uas cov vector tau tuav. muaj peev xwm() – Rov qab rau qhov loj ntawm qhov chaw cia khoom tam sim no faib rau lub vector qhia raws li tus naj npawb ntawm cov ntsiab lus. resize(n) – Resizes lub thawv kom nws muaj 'n' ntsiab.

Ib yam li ntawd, qhov loj tshaj qhov loj ntawm vector hauv C ++ yog dab tsi?

max_size() yog qhov theoretical siab kawg tus naj npawb ntawm cov khoom uas tuaj yeem muab tso rau hauv koj vector . Ntawm 32-ntsis system, koj tuaj yeem nyob rau hauv txoj kev xav faib 4Gb == 2^32 uas yog 2^32 char qhov tseem ceeb, 2^30 int qhov tseem ceeb lossis 2^29 ob tus nqi.

Muaj pes tsawg lub ntsiab lus tuaj yeem tuav C ++?

11 Teb. Muaj ob qhov kev txwv, ob qho tib si tsis raug cai los ntawm C++ tab sis theej los ntawm hardware. Thawj qhov txwv (yuav tsum tsis txhob mus txog) yog teem los ntawm kev txwv ntawm hom loj siv los piav qhia qhov ntsuas hauv array (thiab qhov loj ntawm nws).

Pom zoo: