01-12-2024 04:56 PM
The very first two elements of "Wall Indices" are the same (3878).
The original code passes both values through since 3878 isn't a "hole" which is why it gives an answer that is 1 larger in size compared to the Map/Set examples. If 3878 was a hole, the original code would only remove the first instance while Map/Set would remove both.
01-13-2024 11:54 AM - edited 01-13-2024 02:53 PM
(Sorry, could not look at your VI, so maybe I misunderstood)
<content deleted>
Edit: Sorry, I misunderstood the problem...
01-13-2024 03:07 PM - edited 01-13-2024 03:14 PM
@BertMcMahan wrote:
Well heck then, here's a much simpler version:![]()
Here's an even simpler version.
~20ms in my testing (on a W10 VM where your solution is about 100ms) producing the exactly same result as the original code.
01-15-2024 09:14 AM
@LuminaryKnight wrote:
So I'm not entirely sure I follow what you're trying to do here. Let me know if I didn't duplicate it correctly. But this nearly broke my machine. Filled up my memory instantly.
That looks correct to me. I just tried with 500k Wall and 10k holes and it was almost instant. It is Array Subset you're using, right? (The picture i posted was a Snippet, if you save it to disk you should be able to drag it into a VI and get the code)
01-15-2024 09:34 AM
Version 2, with Maps ... i just realized it's basically identical to Altenbachs ... i guess that's a good thing. 🙂
01-15-2024 11:44 AM
@Yamaeda wrote:
That looks correct to me. I just tried with 500k Wall and 10k holes and it was almost instant.
It does not preserve the original order of the elements. You also need to be careful if the input is a diagram constant, because the entire thing could potentially be constant folded once debugging is disabled, making any benchmarking meaningless.
Whenever I hear "almost instant", I am reminded of the comic Steven Wright who once said: "I put instant coffee in a microwave oven and almost went back in time" (The joke made sense back in the time where these ovens were touted as being so much faster than regular cooking.)
@Yamaeda wrote:
Version 2, with Maps ... i just realized it's basically identical to Altenbachs ... i guess that's a good thing. 🙂
I was using a Set, not a Map (small difference)! 😄
01-18-2024 11:21 AM
@altenbach wrote:
@BertMcMahan wrote:
Well heck then, here's a much simpler version:![]()
Here's an even simpler version.
~20ms in my testing (on a W10 VM where your solution is about 100ms) producing the exactly same result as the original code.
Greatly appreciated. I did not even know these functions were available. Adding new stuff to my bag of tricks. Thank you everyone!
01-18-2024 11:32 AM
@LuminaryKnight wrote:
Greatly appreciated. I did not even know these functions were available. Adding new stuff to my bag of tricks. Thank you everyone!
Sets and Maps are extremely useful and relatively new (introduced in LabVIEW 2019 and probably first suggested in 2010 😄 ).