LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Darin.K

Swap Array Elements Primitive

Status: New

Is it immediately obvious to you what the following code does?

 

SwapArrayElements.png

 

This rats nest simply swaps two elements in an array, a very common operation when trying to operate on a large array in-place.  The In Place Element Structure helps the looks a little, but I find the performance to lag when used in a tight loop, you know, the kind you encounter when you are trying to operate on large arrays.

 

SwapArrayElementsIPE.png

 

I would like a simple primitive (sorry too lazy for a picture) which simply swaps two elements in an array.  It should be similar to the Replace Array Subset function, except for two sets of index inputs and no subset input.  If you want to really make my day be sure to allow disabled inputs to swap rows and columns in one shot for 2D arrays, or pages or volumes or whatever in higher dimensional arrays.

22 Comments
dadreamer
Active Participant

It's nowhere and available with the scripting only. You may read this thread to know the details for this node. SVE is a simple node internally, so theoretically could be quickly reworked to accomplish the idea's task for NXG at least (if Memory Manager's SwapBlock is translated to NXG as well).

 

For VIMs any code may have any look, it really doesn't matter. It's just a question of performance and aesthetics.

wiebe@CARYA
Knight of NI

A copy paste from your snippet was easier than scripting 👍.