Jump to content

Effective way to insert and delete middle array element.


Recommended Posts

Hi all,

I have big array of clusters.

I need effectively insert or delete middle elements. In my opinion linked list will be the right chose in C.

What about labview ? I can use implementation via fixed size array of data elements and two arrays of integers represents previous and next pointers (in this case endexes to the data aray).

But everything exists simpler more effective way, isn

Link to comment
I have big array of clusters.

I need effectively insert or delete middle elements. In my opinion linked list will be the right chose in C.

What about labview ? I can use implementation via fixed size array of data elements and two arrays of integers represents previous and next pointers (in this case endexes to the data aray).

But everything exists simpler more effective way, isn

Link to comment
You are trying too hard to think in C. Just use the built-in functions. In the array palette you will find three native functions, "Replace Array Subset", "Insert Into Array" and "Delete From Array". These will provide the tools you need for that simpler more effective way.

Those "native" VIs potentially require large amounts of memory allocation and/or copying. That is a problem whether in LabVIEW or in C or in java or anywhere else. When you're trying to do something fast, spurious memory allocations can easily kill your efficiency, and they're not that easy to prevent in LabVIEW. Many times it allocates blocks of memory in completely unnecessary places, but I haven't figured a way to convince it otherwise... that doesn't make things easy when doing RT work, for example.

Vladimir: unless someone else replies with the perfect solution, try and test against your requirements. And what are the requirements? Less time? Less memory?

Link to comment
Those "native" VIs potentially require large amounts of memory allocation and/or copying. That is a problem whether in LabVIEW or in C or in java or anywhere else. When you're trying to do something fast, spurious memory allocations can easily kill your efficiency, and they're not that easy to prevent in LabVIEW. Many times it allocates blocks of memory in completely unnecessary places, but I haven't figured a way to convince it otherwise... that doesn't make things easy when doing RT work, for example.

Vladimir: unless someone else replies with the perfect solution, try and test against your requirements. And what are the requirements? Less time? Less memory?

True. I didn't think of the memory allocation issues and I probably misunderstood the question. I agree that the static array with "replace array subset" is a good choice. Can't think of anything else in pure G.

Link to comment

Several different ways you could approach this. If you really want to get fancy you could use templates and create an actual spawned linked list.

If you use the array ideas suggested earlier, remember that the replace element doesn't change memory, only the add and delete, in which case I'd preallocate a large enough array and keep track of the available elements in a side array.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.