samedi 23 septembre 2017

How can I make this getter method more efficient in C++

I am trying to improve my getter method here. How can I achieve it ?

struct run
{
    int m_stop;
    int m_value;
};
std::vector<run> m_runs;

int get(int index) const
{
    for (auto const& r : m_runs)
    {
        if (r.m_stop > index)
            return r.m_value;
    }

}

Aucun commentaire:

Enregistrer un commentaire