生成与 c++ 中的周期性晶格平移相对应的排列;
假设我有一个字符序列 (ABCDEF....),位于数组或字符串或任何合适的数据结构中,并且这些字符分布在 3D 晶格的各个位置上,使得位置 1 对应于坐标 (1, 1,1) 等等。当我对此晶格执行任何操作时,即 x 方向上的周期性平移,这意味着所有元素都在 x 方向上循环移位,这应该相应地改变我的数据结构中的字符序列。我的问题:哪些数据结构/函数/库可以在 C++ 中有效地完成这些排列?速度很重要,因为这必须进行多次。
Suppose I have a sequence of characters (ABCDEF....), in an array or a string or any suitable data structure, and these characters are distributed over the sites if a 3D lattice, such that position 1 corresponds to coordinates (1,1,1) and so on. When I perform any operation on this lattice, i.e., periodic translation in x-direction which means all elements are shifted cyclically in the direction of x, this should alter the sequence of characters in my data structure accordingly. My question: which data structures/functions/libraries can do these permutations efficiently in c++? Speed is important because this has to be done many times.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在一维中,您可以将其视为循环双向链表。优点是您可以使用 STL 列表 容器,让您的生活更轻松。
将其扩展到 3D 的练习留给读者。
In 1D, you could think about it as a circular doubly linked list. The advantage would be that you could use an STL list container and make your life easier.
The exercise of extending this to 3D is left to the reader.