How to k-shuffle an array with STL?
<p>I am testing an algorithm that sorts a k-sorted array (every element is at most k-positions away from its correct sorted position).</p>

<p>I am having a hard time generating test data -- I can't randomly swap elements by k-positions because I may end up swapping an element twice. I could track which elements I swapped but then I need O(N) space.  I could also use a random-heap of size k + 1, but that sounds silly.</p>

<p>Is there anything built into the STL that can help me with this? This seems like a common problem, but my brief research only turned up algorithms for total shuffles (I think STL implements Fisher-Yates).</p>