Details

Type: Enhancement

Status: Open

Priority: Major

Resolution: Unresolved

Affects Version/s: None

Fix Version/s: None

Component/s: None

Labels:
Description
Is it possible to implement an efficient reverse on a rrbvector resulting in an rrbvector? This would be pretty useful in scenarios like the 2opt neighborhood for local search for the Traveling Salesman Problem. The complete operation is as follows.
Given: a = [a_0, a_1, ..., a_{n1}, a_{n}, a_{n+1}, ..., a_{n+k2}, a_{n+k1}, a_{n+k}, ..., a_{n+k+m1}]
Goal: [a_0, a_1, ..., a_{n1}, a_{n+k1}, a_{n+k2}, ..., a_{n+1}, a_{n}, a_{n+k}, ..., a_{n+k+m1}]
Possible Clojure implementation of the described operation:
(let [x (subvec a 0 n), y (subvec a n (+ n k)), z (subvec a (+ n k))] (catvec x, (reversevec y), z))