简体   繁体   English

在std或boost中是否有类似round_advance的东西?

[英]Is there something like circular_advance avaliable in std or boost?

lets say I want to go through container in a circular way: 假设我想以循环方式遍历容器:

idx = 0, idx =1 .. idx = size()-1, idx =0, idx =1 ... idx = 0,idx = 1 .. idx = size()-1,idx = 0,idx = 1 ...

Is there a way to do in with std or boost? 有没有办法处理性病或升压? I know that algorithms operate on ranges not on containers so I guess Im out of luck, but I just wanted to check. 我知道算法在范围上而不是在容器上运行,所以我想我很幸运,但是我只是想检查一下。

PS No need for manual implementations, it is trivial(if you dont forget about seq points :P ), just PS不需要手动实现,这很简单(如果您不忘记seq points:P),

curr_idx= (curr_idx+1) % my_cont.size()

我不知道类似的任何功能,但是此答案显示了如何使用Boost.Iterator创建在集合上循环的迭代器适配器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM