C++??STL
???????????? ???????[ 2016/11/2 10:42:41 ] ????????STL C++
??????????δ????????????仰??????????????????
????sort??rotateArray.begin()??rotateArray.end()??;
?????????????????????sort???÷???
????sort???????÷?
???????д??e??????O(n^2)?????????????????????????п???д???
????STL?????и?sort????????????????????????????n*log2(n)???????????????????????????
??????????????????????????????????????????????????????????????????????????????β?????????????
?????????????????????[a??b)??????????????????int a[100]??????a[0]??a[99]??????????????дsort(a??a+100)????????????????????
???????????“AC?????”??????????????????t???0??len-1?????????дsort(t??t+len);
??????????v?????????sort(v.begin()??v.end());//?????????????????÷?
???????????????????????????????????????С????????????????????????????string??
???????????ж???С????????????????????????????????????????????——???????????????????????????????????????bool??????漲??????????????“С??”???????????????鰴???????У???????????????????cmp
????bool cmp(int a??int b)
????{
????return a>b;
????}
????????????дsort(a??a+100??cmp);
????????????????????????node
????struct node{
????int a;
????int b;
????double c;
????}
?????????node?????????node arr[100]??????????????????a????????У????a?????????b????????У????b?????????c???????С?
????????д???????????????
???????????????Σ?
????bool cmp(node x??node y)
????{
????if(x.a!=y.a) return x.a
????if(x.b!=y.b) return x.b>y.b;
????return return x.c>y.c;
????}
?????????дsort(arr??a+100??cmp);
????qsort(s[0]??n??sizeof(s[0])??cmp);
????int cmp(const void *a??const void *b)
????{
????return *(int *)a-*(int *)b;
????}
?????????int????????????
????int num[100];
????Sample:
????int cmp ( const void *a ?? const void *b )
????{
????return *(int *)a - *(int *)b;
????}
????qsort(num??100??sizeof(num[0])??cmp);
??????????char?????????????int?????
????char word[100];
????Sample:
????int cmp( const void *a ?? const void *b )
????{
????return *(char *)a - *(int *)b;
????}
????qsort(word??100??sizeof(word[0])??cmp);
??????????double???????????????????
????double in[100];
????int cmp( const void *a ?? const void *b )
????{
????return *(double *)a > *(double *)b ? 1 : -1;
????}
????qsort(in??100??sizeof(in[0])??cmp)??
???????????????????
????struct In
????{
????double data;
????int other;
????}s[100]
????//????data?????С????????????????????????????????data???????????????ο??????????д
????int cmp( const void *a ??const void *b)
????{
????return ((In *)a)->data - ((In *)b)->data ;
????}
????qsort(s??100??sizeof(s[0])??cmp);
?????塢?????
????struct In
????{
????int x;
????int y;
????}s[100];
????//????x??С??????????x????????y???С????
????int cmp( const void *a ?? const void *b )
????{
????struct In *c = (In *)a;
????struct In *d = (In *)b;
????if(c->x != d->x) return c->x - d->x;
????else return d->y - c->y;
????}
????qsort(s??100??sizeof(s[0])??cmp);
???????????????????????
????struct In
????{
????int data;
????char str[100];
????}s[100];
????//??????????????str????????????
????int cmp ( const void *a ?? const void *b )
????{
????return strcmp( ((In *)a)->str ?? ((In *)b)->str );
????}
????qsort(s??100??sizeof(s[0])??cmp);
??????????????????????cmp
????int cmp(const void *a??const void *b) //???cmp???????????1????????е???????????
????{
????struct point *c=(point *)a;
????struct point *d=(point *)b;
????if( calc(*c??*d??p[1]) < 0) return 1;
????else if( !calc(*c??*d??p[1]) && dis(c->x??c->y??p[1].x??p[1].y) < dis(d->x??d->y??p[1].x??p[1].y)) //??????????????????????????
????return 1;
????else return -1;
????}
?????????????????sort???÷???????????????STL??????????
??????????????STL????????????磩
?????????????
????STL??Standard Template Library?????????????????????й?????????Ч??C++???????????????C++????????C++ Standard Library???У???ANSI/ISO C++??????μ?????????????????????????????????????????????????????????????????????????C++????????????????????????????????????????????????
????????????????????STL???????????????????????generic programming??????????????μ????????????????requirements????????concept????????model??????????container????????algorithmn???????????iterator???????OOP??object-oriented programming???е?????polymorphism????????????????????????ü?????
??????????ο???????STL??????????????????type parameterized??????????????????????????????C++???????г????????????--??壨template????????????κ?????汾??STL?????????????????????????STL????????????????????顣??????????????C++?????????STL????????????
????????STL?????????
??????????Container??????????????????list??vector????deques ????????????????????????????е????????????????????????????????? ????????Iterator????????????????ж????????????磬??????????????????list??vector?е??????Χ??????????????????????????C++??????????????????????????????????????Щ??????operator*()?????????????????????????????????? ????Algorithm???????????????????е????????庯???????磬STL??sort()???????vector?е??????????????find()?????????list?е????????????????????????????????????????????????????????鵽?????????????κ???????????? ?o?????Function object???o???(functor)?????????????function object???????????????()????????struct????????????? ????????????Adaptor?? ???????????allocator???????????????????????1.?????????????? 2.????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11