Returning an empty vector of strings if key is not found

前端 未结 4 798
花落未央
花落未央 2021-01-13 09:34

I know it is a very bad idea, so other suggestions on how to do it efficiently will be well-received.

Here\'s the thing. I have map

4条回答
  •  -上瘾入骨i
    2021-01-13 10:07

    I think the operator [] can help you, it will return a empty value(a empty vector here). So all you need to do is

    vector returnEdges(string key) 
    {
        return outgoing[key];
    }
    

提交回复
热议问题