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 / [code] SArray - Arrays Built From Strings

Author
Message
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 1st Jun 2014 23:22 Edited at: 2nd Jun 2014 21:37
In light of the problems with arrays I've been fighting for some time I made this.



It's essentially a dynamic array of floats from index 0 to size-1. The code wouldn't be too hard to adapt for integers, but I felt using floats would provide a better basis. I don't at all intend to replace AGK's arrays with this inefficient alternative but these arrays give you some unique powers. For example, you can have 2D arrays of varied lengths. Create an array of SArrays
and each index can contain an array of independent length. They can also be passed in an out of functions and can be created within functions without concern for AppGameKit errors. Of course they don't support UDTs, but if you're willing to go digging deep into the realm of Strings they certainly could Just thought I'd share it as an alternative I included bubble sort mostly as a method of testing. Don't mock the sort . It took under a minute to write!

Edit: If you're here it's likely you'd prefer this.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Jun 2014 13:47
I had a similar idea using memblocks as memblock ID's are also easy to pass around. It's also a little quicker to access data from a memblock than parsing a string (I believe) but I never finished my implementation.

If Paul weren't working on arrays in V2 and I weren't so busy I'd finish it...
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 2nd Jun 2014 17:25 Edited at: 2nd Jun 2014 21:36
Quote: "I had a similar idea using memblocks as memblock ID's are also easy to pass around. It's also a little quicker to access data from a memblock than parsing a string (I believe) but I never finished my implementation.

If Paul weren't working on arrays in V2 and I weren't so busy I'd finish it.."

Sounds more complex but maybe I'll try that. That would certainly be another good alternative. I won't trust the stability of V2 for a while now so I figure it's worth it

Edit: Finished it. It was actually easier to write than the string code

Login to post a reply

Server time is: 2024-11-25 05:36:03
Your offset time is: 2024-11-25 05:36:03