Home > Net >  Comparator function for upper_bound or lower_bound for vector of vector
Comparator function for upper_bound or lower_bound for vector of vector

Time:09-01

How(is it possible) to write a compartor function for upper_bound for a vector of vector such that it compares all indexes of inner vector and get a element in which corresponding element are larger

For example for a given arr

vector<vector<int>>arr={{0,1,1},{0,1,2},{0,2,1},{1,2,3},{4,1,2},{4,3,2}}

the upper bound of {0,1,1} should give {1,2,3} i.e. all corresponding element should be larger.

CodePudding user response:

I will assume that the predicate you have in mind is "all values in the inner vectors must be greater".

upper_bound requires a vector of data that is partitioned with respect to the given sample.

In the given example, the data vector is not partitioned w.r.t. {0,1,1} (and the assumed predicated), hence, you cannot even use upper_bound.

The answer is, therefore: The problem and the proposed solution are incompatible. Stated differently:

is it possible

No.

  • Related