Fastest way to sort a list of number and their index

前端 未结 8 1168
萌比男神i
萌比男神i 2021-02-14 21:15

I have a question that could seem very basic, but it is in a context where \"every CPU tick counts\" (this is a part of a larger algorithm that will be used on supercomputers).<

8条回答
  •  粉色の甜心
    2021-02-14 21:32

    struct SomeValue
    {
        unsigned long long val;
        size_t index;
        bool operator<(const SomeValue& rhs)const
        { 
           return val < rhs.val;
        }
    }
    
     #include 
     std::vector somevec;
     //fill it...
     std::sort(somevec.begin(),somevec.end());
    

提交回复
热议问题