index or position in std::set

前端 未结 3 1847
别那么骄傲
别那么骄傲 2020-12-09 21:28

I have a std::set of std::string. I need the \"index\" or \"position\" of each string in the set, is this a meaningful concept in the context?

I guess find() will re

3条回答
  •  青春惊慌失措
    2020-12-09 21:55

    I don't think it is meaningful - set's are 'self keyed' and sorted thus the 'index' would be invalidated when the set is modified.

    Of course it depends upon how you intend to use the index and if the set is essentially static (say a dictionary).

提交回复
热议问题