[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > JASS Resources


JASS Resources Find JASS code snippets and functions here or write your own and post it on the Submissions sub-forum.

Reply
 
Thread Tools
Old 03-23-2012, 07:52 AM   #16 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,906
Nestharus has disabled reputation
And updated
Nestharus is offline   Reply With Quote
Old 06-07-2012, 10:33 PM   #17 (permalink)
Registered User Fingolfin
Panzer, VORWÄRTS!
 
Fingolfin's Avatar
 
Join Date: Jan 2009
Posts: 2,085
Fingolfin is a splendid one to behold (818)Fingolfin is a splendid one to behold (818)Fingolfin is a splendid one to behold (818)Fingolfin is a splendid one to behold (818)
Finally something i have use for.
Will use it to sort nodes in A* searches and to get closest ports in WiF. :)
__________________
My models

Fingolfin is offline   Reply With Quote
Old 12-11-2012, 02:58 PM   #18 (permalink)
Registered User Hashjie
I salute you kind sir ಠ_ರ
 
Hashjie's Avatar
 
Join Date: Apr 2009
Posts: 1,481
Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)
Is it me, or does it say that the compare method does not exist when implementing this allocator?

Jass:
exitwhen (0 == parent or compare(parent.node.value, value))

the library clearly states:
Jass:
/*   Interface:
*       private static method compare takes thistype value1, thistype value2 returns boolean
*           -   < for minimum heap
*           -   > for maximum heap
*/

but I can't see it inside the module :/?
__________________
Knowledge and patience is key to success.
Knowledge is acquired through a learning process either theoretically or practically.
The more you know and can keep your calm, the more successfull you will be in life.
Hashjie is offline   Reply With Quote
Old 12-11-2012, 05:51 PM   #19 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,906
Nestharus has disabled reputation
Look up what an interface is : )
__________________

Anime-Planet.com - anime | manga | reviews
Nestharus is offline   Reply With Quote
Old 12-11-2012, 08:51 PM   #20 (permalink)
Registered User Arhowk
User
 
Arhowk's Avatar
 
Join Date: Aug 2007
Posts: 2,256
Arhowk is a jewel in the rough (184)Arhowk is a jewel in the rough (184)
Quote:
Originally Posted by Hashjie View Post
Is it me, or does it say that the compare method does not exist when implementing this allocator?

Jass:
exitwhen (0 == parent or compare(parent.node.value, value))
>>

Jass:
exitwhen (0 == parent or parent.node.value > (or < o.O) value)
Arhowk is offline   Reply With Quote
Old 12-11-2012, 09:03 PM   #21 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,906
Nestharus has disabled reputation
no..

look up interface in programming >.<

edit
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
__________________

Anime-Planet.com - anime | manga | reviews
Nestharus is offline   Reply With Quote
Old 12-11-2012, 09:05 PM   #22 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,699
Magtheridon96 has a brilliant future (1809)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
You have to write your own compare method in the struct so that the module would work with it.

This is what makes the Binary Heap resource very flexible. You can define how it decides whether something is "greater" or not.

Remember, this doesn't need to do it based on whether the actual values are greater or not ;)

edit
If you want a minimum heap, inside your struct, define the following method:

Jass:
static method compare takes thistype value1, thistype value2 returns boolean
    return integer(value1) < integer(value2)
endmethod

If you a maximum heap, define this:

Jass:
static method compare takes thistype value1, thistype value2 returns boolean
    return integer(value1) > integer(value2)
endmethod
__________________
Magtheridon96 is offline   Reply With Quote
Old 12-11-2012, 09:19 PM   #23 (permalink)
Registered User Hashjie
I salute you kind sir ಠ_ರ
 
Hashjie's Avatar
 
Join Date: Apr 2009
Posts: 1,481
Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)
Hmm odd, I'm getting a compiler error saying: Expected: create.
I'm using something like:

Jass:
interface myInterface
    private static method compare takes thistype value1, thistype value2 returns boolean
endinterface

struct myStruct extends myInterface
    static method compare takes thistype value1, thistype value2 returns boolean
        return integer(value1) > integer(value2)
    endmethod
endstruct

It's showing this error for the interface method. Am I using it in a wrong way? I've looked through some tutorials and couldn't figure out why.
Is it expecting a static create method :/? Because I tried adding that inside both my struct and my interface, the error still pops up.

I know that it's useful to have interfaces as they can set standards for your structs.
Some structs may have different implementations of a specific method then the standard set through the interface, which is why you need to define them inside the struct right?
It's basically something like a parent with children, where the children inherit some of the parents properties and functions unless overridden by the child?
__________________
Knowledge and patience is key to success.
Knowledge is acquired through a learning process either theoretically or practically.
The more you know and can keep your calm, the more successfull you will be in life.
Hashjie is offline   Reply With Quote
Old 12-11-2012, 09:22 PM   #24 (permalink)
Registered User Arhowk
User
 
Arhowk's Avatar
 
Join Date: Aug 2007
Posts: 2,256
Arhowk is a jewel in the rough (184)Arhowk is a jewel in the rough (184)
Quote:
Originally Posted by Nestharus View Post
no..

look up interface in programming >.<

edit
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
lol i so good programmer
Arhowk is offline   Reply With Quote
Old 12-11-2012, 09:36 PM   #25 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,906
Nestharus has disabled reputation
Jass:
struct Heap extends array
    private static method compare takes integer value1, integer value2 returns boolean
        return value1 >= value2
    endmethod

    implement BinaryHeap
endstruct
__________________

Anime-Planet.com - anime | manga | reviews
Nestharus is offline   Reply With Quote
Old 12-11-2012, 09:38 PM   #26 (permalink)
Registered User Hashjie
I salute you kind sir ಠ_ರ
 
Hashjie's Avatar
 
Join Date: Apr 2009
Posts: 1,481
Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)Hashjie is just really nice (283)
Quote:
Originally Posted by Nestharus View Post
Jass:
struct Heap extends array
    private static method compare takes integer value1, integer value2 returns boolean
        return value1 >= value2
    endmethod

    implement BinaryHeap
endstruct
ooooh, I get it. Thanks :D
__________________
Knowledge and patience is key to success.
Knowledge is acquired through a learning process either theoretically or practically.
The more you know and can keep your calm, the more successfull you will be in life.
Hashjie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 05:51 PM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle