Std:: txheeb ua dab tsi?
Std:: txheeb ua dab tsi?

Video: Std:: txheeb ua dab tsi?

Video: Std:: txheeb ua dab tsi?
Video: Txheeb Yus Tus Txiv Rov Qab. 3/27/2023 2024, Cuaj hlis
Anonim

Internal paub meej ntawm std:: ua () hauv C++

Nws txhais tau hais tias npaj cov ntaub ntawv hauv ib qho kev zam, uas tuaj yeem nce lossis txo qis. Muaj kev ua haujlwm ua haujlwm hauv C ++ STL los ntawm lub npe ntawm xaiv (). std:: ua () yog ib qho kev ua haujlwm hauv C ++ Standard Library, rau kev sib piv kev xaiv.

Tom qab ntawd, ib tug kuj yuav nug, std:: ua haujlwm li cas?

std:: pib() yuav rov qab ib qho iterator(pointer) rau thawj lub caij hauv array peb dhau nws. Qhov twg std:: kawg() yuav rov qab ib qho iterator(pointer) mus rau ib qho dhau los ntawm cov khoom kawg hauv cov array peb dhau nws. Yog li peb tuaj yeem hu rau xaiv ua haujlwm los ntawm kev hla nws pib() thiab xaus() zoo li ntawd.

Kuj Paub, yog std:: txheeb ruaj khov? Yog lawm, std:: lis ::kev yog guaranteed yuav ruaj khov . Raws li "C++ Programming Language" (Stroustrup p470), yog, stl :: lis ::kev yog ruaj khov.

Qhov thib ob, dab tsi algorithm ua std:: txheeb siv?

Siv std::sort (los yog std::stable_sort) Nws feem ntau yog ib qho kev siv tau zoo ntawm Introsort algorithm uas pib nrog kev ceev thiab hloov mus rau heapsort thaum lub recursion mus tob heev. The std::sort algorithm tsis tuav cov txheeb ze ntawm cov khoom sib npaug.

Lub tsev qiv ntawv zoo li cas hauv C ++?

xaiv (C++) xaiv yog ib tug generic muaj nuj nqi nyob rau hauv lub C++ Txuj Lub tsev qiv ntawv rau ua kev sib piv sorting. Cov haujlwm tau tshwm sim hauv Standard Template Lub tsev qiv ntawv (STL).

Pom zoo: