<< Back to previous view

[CRRBV-2] Efficient reverse resulting in reversed rrb-vector Created: 20/Dec/13  Updated: 20/Dec/13

Status: Open
Project: core.rrb-vector
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Gunnar Völkel Assignee: Michał Marczyk
Resolution: Unresolved Votes: 0
Labels: enhancement


 Description   

Is it possible to implement an efficient reverse on a rrb-vector resulting in an rrb-vector? This would be pretty useful in scenarios like the 2-opt neighborhood for local search for the Traveling Salesman Problem. The complete operation is as follows.

Given: a = [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}]
Goal: [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}]

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, (reverse-vec y), z))

Generated at Tue Jul 22 16:42:04 CDT 2014 using JIRA 4.4#649-r158309.