How do I search through an array using wildcards

Get help using Construct 2

Post » Fri Mar 11, 2016 1:08 pm

When starting development I used the contains method of the array which worked great without any performance issues. I later needed to allow searching with wildcards, this however introduces a performance issue in the events since I was forced to iterate over the array because the array contains method does not accept wildcards. I've tried the for each method of the arrays and also a simple while loop using regex for both methods to find a match with no success. By no success, I mean without the noticeable performance hit that I get (all animation stops) while the loop completes.
B
3
Posts: 4
Reputation: 183

Post » Fri Mar 11, 2016 8:19 pm

You'll just have to loop through and compare each value. How big is the array? And what kind of searches do you need to make?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,680

Post » Fri Mar 11, 2016 11:05 pm

The array is 1D but has about 50K elements that are going to grow. I need to make wildcard searches for any text in the element. The only other thing I can think of is breaking the array up into categories with a dictionary but this is a huge pain. I guess I will have to do it and hope for some improvements.
What a huge difference between using contains and a loop.
B
3
Posts: 4
Reputation: 183

Post » Fri Mar 11, 2016 11:56 pm

Do you just need to check if the value is in the array (like contains does)? What about doing a regex search on Array.AsJSON?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,680

Post » Sat Mar 12, 2016 3:02 am

Never thought about searching through the json file. I will attempt trying this method first if not successful then I wil break the array into the dictionary. Hopefully I have some success with one of these methods and will update thread as soon as i do.
B
3
Posts: 4
Reputation: 183

Post » Sat Mar 12, 2016 5:46 pm

I had great success with searching through a loaded file. I'm going to stop researching the problem and consider the issue solved. If anyone is curious of what worked:
(1) load entire json file into a global variable(data) at layout start
(2) added delimiters to start and end of searchable text
(3) query the data using "test regex" condition
*** after using this method the animation stop until search completed no longer happens (or at least not noticeable on my test devices) ***
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests