Binary search on vector< struct S> in c++? -
i utilize binary search on vector using stl in c++;
struct z{ int i; int j; }; struct s{ z z; int k; }; vector<s> myvec; binary_search(myvec.begin(),myvec.end(),...); the search status given below .
e.g. binary_search(myvec.begin(),myvec.end(),s2); , s2.z.i = 1 ; s2.z.j =2; s2.k = 4 ; if phone call binary_search these arguments should homecoming true if there exist struct s in vector "myvec" such s.z.i = s2.z.i , s.z.j = s2.z.j , s.z.i!=s2.z.i . @ lastly how sort vector using stl ? it's plenty phone call sort(myvec.begin(),myvec.end()); .
you have provide operator <or comparing function struct s.
c++ vector struct stl binary-search
No comments:
Post a Comment