是否可以在一个rrb-vector上执行高效的倒序操作,以生成一个rrb-vector?这在旅行商问题的局部搜索中的2-opt邻域等场景中将非常有用。整个操作如下。
给定:a = (link: a_0, a_1, ..., a_{n-1}, a_{n}, a_{n+1}, ..., a_{n+k-2}, a_{n+k-1}, a_{n+k}, ..., a_{n+k+m-1})
目标: (link: a_0, a_1, ..., a_{n-1}, a_{n+k-1}, a_{n+k-2}, ..., a_{n+1}, a_{n}, a_{n+k}, ..., a_{n+k+m-1})
描述操作的Clojure实现
(let [x (subvec a 0 n), y (subvec a n (+ n k)), z (subvec a (+ n k))] (catvec x, (reverse-vec y), z))