I have a sorted list
. For example, my list
is:
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Actually, I have list of objects of my class with int property
, on which the list is sorted.
I want to calculate number of objects, which have value of this property
between two values
.
I looking for the following python equivalent.
int main [] {
int myints[] = {10,20,30,30,20,10,10,20};
std::vector v[myints,myints+8]; // 10 20 30 30 20 10 10 20
std::sort [v.begin[], v.end[]]; // 10 10 10 20 20 20 30 30
std::vector::iterator low,up;
low=std::lower_bound [v.begin[], v.end[], 20]; // ^
up= std::upper_bound [v.begin[], v.end[], 20]; // ^
std::cout