STL Rope - when and where to use

后端 未结 5 1442
無奈伤痛
無奈伤痛 2020-11-30 02:57

I was wondering under what circumstances you would use a rope over another STL container?

5条回答
  •  旧时难觅i
    2020-11-30 03:48

    There is a lot of emphasis here on strings made up of characters, but rope is simply a 1D sequence with fast insertions and deletions (anywhere within the sequence).

    It seems a bit surprising that such a basic capability is rarely required for anything (other than strings). Where would I use a rope of integers? I don't know, because manipulating it requires the indices to come from somewhere.

    The best contrived real-world example would be where I'm making a UI to let the user view a dataset made up of thousands of images, and the user needs to be able to delete some of them and rearrange the order of the others.

提交回复
热议问题