Home > Back-end > STD there is a similar sort of thing
STD there is a similar sort of thing
Time:10-28
Memory management probably tens of millions of people, the amount of money each wallet, and in a dynamic change, I just want to use the fastest speed to find a moment ago ten billionaires, STD what's inside the appropriate data structure to deal with it? Himself as a data structure is easy, use SQL easier, but I wanted to know STD inside have ready
CodePudding user response:
Consider using the VECTOR container support, according to custom rules automatic sorting
CodePudding user response:
# include & lt; Iostream> # include & lt; Cstdlib> # include & lt; Climits>
Int main () { Int a []={2, 99, 0, 743, 2, INT_MIN, 4}; Constexpr STD: : size_t size=sizeof a/sizeof * a;
STD: : tree (a, a, the size, sizeof * [] (const void * a, const void * b) { Int arg1=* static_cast & lt; Const int * & gt; (a); Int arg2=* static_cast & lt; Const int * & gt; (b);
If (arg1 & lt; Arg2) return 1; If (arg1 & gt; Arg2) return 1; return 0;
//return (arg1 & gt; Arg2) - (arg1 & lt; Arg2);//the abbreviation of feasible //return arg1, arg2;//the abbreviation of errors (if any INT_MIN failure) });
For (int ai: a) STD: : cout & lt; & lt; Ai & lt; & lt; "'; }
CodePudding user response:
Because I just want to find tens of millions of data inside a few, so if you are looking for, to do the sorting, then the price of article to a few data sorting tens of millions of data is quite large, so I hope the best this container is orderly, and can dynamically when modify the value to be able to be orderly, STD does not have the appropriate container, if not I will be the