Data structure (Map-like implementation) in C++
You should implement a private function find, that returns the index of a key

const int find(const int key) const
{
    for (unsigned i=0; i &lt; pairs.size(); ++i)
    {
        if(pairs[i][0] == key )
        {
            return i;
        }
    }
    return -1;
}


This should simplify your functions considerably

const int size(const int key) const
{
    const int index = find(key);
    if (index == -1)
        return -1;
    return pairs[index].size() - 1;  
}

const int* data(const int key) const
{
    const int index = find(key);

    if( index == -1 )
        return nullptr;
    return &amp;pairs[index][1];
}

void insert(const int key, const int value)
{
    const int index = find(key);

    if( index != -1 )
    {
        pairs[index].push_back(value);
    }
    else
    {
        std::vector&lt;int&gt; v = {key, value};
        pairs.push_back(v);
    }
}


Generally i would strongly recommend to split keys and values. One possibility would be to create a std::pair

std::vector&lt;std::pair&lt;int, std::vector&lt;int&gt;&gt;&gt; pairs;


Otherwise you could split it into a map and a vector.