在正向迭代和反向迭代之间切换
我有一个动画类,它将帧存储在 std::list 中,头文件声明一个迭代器,我使用时间递增迭代器。我的动画工作正常,直到我尝试反转动画(从当前位置),我无法递减迭代器(双向吧?)。我也考虑过存储反向迭代器,但找不到在两者之间切换的好方法。
如何在正向迭代和反向迭代之间无缝切换(无需从 std::list 的开头开始)。
I have a animation class which stores the frames in a std::list, the header file declares a iterator, I increment the iterator using time. My animations are working fine until I try to reverse the animation (from the current position), I can't decrement the iterator (bidirectional huh?). I've thought about storing a reverse iterator too but can't find a nice way to switch between the two.
How can I seamlessly switch between forward iterating and reverse iterating (without starting from the beginning of the std::list).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够递减列表迭代器;如果没有看到您的代码及其产生的错误,我无法猜测那里出了什么问题。
但是,将动画表示为通用迭代器范围可能更方便:
You should be able to decrement a list iterator; without seeing your code, and the error it produces, I can't guess what's going wrong there.
However, it might be more convenient to represent an animation as a generic iterator range:
“我无法减少迭代器”是什么意思?
在我的 Visual C++ 2010 上,这有效:
What do you mean "I can't decrement the iterator"?
On my Visual C++ 2010, this works: