wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 10-09-2009, 01:35 PM   #1
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default SortUtils

SortUtils allows you sort arrays of reals, units and structs efficiently.

-It uses a QuickSort/InsertionSort hybrid.
-It is based on dynamic arrays and array pointers.
-It can sort a real array from least to greatest. (Read backwards for greatest to least).
-It can sort a unit array or struct array according to the values in a parallel real array.
-It can sort a unit array or struct array according to a SortFunc that can specify any sorting criteria.

The documentation is like a novel; be warned.

Expand JASS:

Last edited by grim001 : 11-24-2009 at 10:25 AM.
grim001 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 10-12-2009, 07:10 PM   #2
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

I was going over this and it is actually rather cool. I don't have the time to verify that it does all of the things that it says it does, but if you respond to this and say that it does, that'll be good enough.

Once you do that, I think I will approve this. I really like the API and it could prove incredibly useful for people. I also really like how thorough the documentation is, I know exactly how to use this library after having read it.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 10-12-2009, 07:15 PM   #3
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

This is kinda cool, I see many uses right now, just think about it:

An system to sort for best players (in a hero arena or in general)
For closest distance units.
... and even more.

This might be in my new AoS, if it works without bugs.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 10-12-2009, 10:20 PM   #4
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

I originally created this because I needed fast distance sorting for an aura system, but eventually I came up with this way to generalize it, so I'm happy with the way it turned out.

I did try partially-recursive and non-recursive variations on quicksort, and it didn't do any better than this recursive implementation in benchmarks. I always assumed that recursive algorithms would be slow in JASS, but they seem to do alright.

I tested it heavily so I know that each function does what it says it does. There shouldn't be any bugs, as they'd wind up being incredibly apparent given the nature of this library.

Last edited by grim001 : 10-14-2009 at 12:59 AM.
grim001 is offline   Reply With Quote
Old 10-13-2009, 02:15 AM   #5
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Then I do declare this approved.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 10-28-2009, 05:11 PM   #6
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Updated.
  • If you intend to use SortUtils with a library that makes heavy use of dynamic arrays and you are worried about instance limits, a special textmacro has been provided to solve that problem. If you use this textmacro within a scope or library, the RealArrays/UnitArrays/StructArrays used within that scope or library will magically have their own instance limit. The textmacro must be placed above any calls to the SortUtils API. Also, you will be required to declare a private constant integer MaxArraySize within that scope or library, which will be used within it.
grim001 is offline   Reply With Quote
Old 11-20-2009, 09:00 AM   #7
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Updated.
  • Documentation, code and efficiency improvements.

Nested textmacros will let me cut the size of the library in half, so it will probably get another update once those come out.
grim001 is offline   Reply With Quote
Old 11-24-2009, 06:47 AM   #8
Tot
6
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

Expand SortUtils-Code:

hasn't it to be UnitArray/StructArray?


anyway, this is really cool, but I'd make a textmacro to let the user sort every thing from integer to lightnings and back
some kind of //! textmacro SortUtils takes TYPE, NULL, SCOPE
you're using introsort and I've read on wikipedia, that it works best with a Threshold of 16
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr

Last edited by grim001 : 11-24-2009 at 08:18 AM.
Tot is offline   Reply With Quote
Old 11-24-2009, 08:11 AM   #9
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Tot
I'd make a textmacro to let the user sort every thing from integer to lightnings and back
If you want to sort stuff other than reals or units, that's what StructArrays are for. The whole point of this is to not be one of those lame textmacro-based sorting libraries.

Also, updated.
  • Altered the sorting algorithm. Everything sorts about 15% faster now.
  • Set the default threshold to 16 for some reason.

Last edited by grim001 : 11-24-2009 at 10:29 AM.
grim001 is offline   Reply With Quote
Old 05-23-2011, 02:35 AM   #10
SanKakU
User
 
Join Date: Jan 2009
Posts: 133

SanKakU has a little shameless behaviour in the past (-1)

Send a message via AIM to SanKakU Send a message via MSN to SanKakU Send a message via Yahoo to SanKakU
Default

i like this. should save me time with the computer sorting things for me :)
SanKakU is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 01:18 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services