Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Compare two arrays?

Author
Message
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 11th Jul 2017 19:13
Is there a fast and efficient way to compare two arrays in AppGameKit? Is a function with a loop that goes through the two arrays the fastest way?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jul 2017 19:41
what is in the array? int string struct?
AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 11th Jul 2017 19:53 Edited at: 11th Jul 2017 19:54
Strings, or integers. I am currently using one string and manipulating it with mid and concatination. But it's probably really inefficient, but useful for comparisons.

If I use an array instead, I could use either strings or the char-int values depending on memory and speed.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Jul 2017 22:38 Edited at: 12th Jul 2017 02:05
for t =1 to 20
for n = 1 to 20
for x = 1 to 20
for y=1 to 20
if one_array[t,n].array = two_array[x,y].array then exit
next y
if one_array[t,n].array = two_array[x,y].array then exit
next x
if one_array[t,n].array = two_array[x,y].array then exit
next n
if one_array[t,n].array = two_array[x,y].array then exit
next t



If using single dimension arrays with no type

for t =1 to 20
for x = 1 to 20
if one_array[t] = two_array[x] then exit //exits loop if true
next x
if one_array[t] = two_array[x] then exit //exits loop if true
next t


Would this work?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Jul 2017 08:50
if you will compare strings you can compare the length before you compare the text.
if you need compare items again and again maybe create a checksum or id.
AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)

Login to post a reply

Server time is: 2024-05-22 07:47:05
Your offset time is: 2024-05-22 07:47:05